Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use 'SELECT * FROM <tablename> FOR UPDATE' this query in Oracle and update record how can I use it in sql server? for updating my records
Posted
Updated 16-Mar-16 19:28pm
v2

You can use use locking hints[^] to do that in SQL Servet
SQL
BEGIN TRANSACTION

SELECT * FROM MyTable WITH (UPDLOCK) WHERE Id = 1

-- update here

COMMIT

Or you can set the transaction level[^] to serializable.
 
Share this answer
 
SQL
UPDATE 
    Table 
SET 
    Table.col1 = other_table.col1, 
    Table.col2 = other_table.col2 
FROM 
    Table 
INNER JOIN 
    other_table 
ON 
    Table.id = other_table.id  
 
Share this answer
 
See Google[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900