sql server - Update row entries using Transact-SQL -


i have sql server 2014 database called database.main has columns type , code.

i need modify existing transact-sql script select rows have type equal myobject.main , change code integer 1000.

how can in transact-sql?

begin try     begin tran update_table;      commit; end try begin catch   print 'error encountered updating entries'   print error_message()   rollback; end catch 

answer

based on answer raul below solution this:

begin try     begin tran update_table;         update database.main         set code = 1000         type = 'myobject.main';     commit; end try begin catch   print 'error encountered updating entries'   print error_message()   rollback; end catch 

a simple update command do?

update table_name set code = 1000 type = 'myobject.main'; 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -