Hi i want to make a stored procedure that will join 2 table and will check some values to update.
We will use FETCH to make a update process for each record.
But we are considering performance. Is this a bad idea to use FETCH?
Example:
Table1
BookID
BookName
Table2
RatingID
BookName
BookID
We will join this two tables like this.
SELECT * FROM Table2
LEFT JOIN Table1 ON Table2.BookName = Table1.BookName
WHERE Table2.BookID = 0
For each record which this query pulls, we will make an UPDATE to set Table1’s bookID to Table2’s BookID column.
Yes.
You should nearly always strive to avoid cursors in SQL Server and use set based alternatives instead.
The
UPDATEstatement does supportJOINs to other tables.