Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 what is return when execute update statement?

Author  Topic 

beliveinmyshelf
Starting Member

15 Posts

Posted - 2008-09-24 : 22:18:54
please advice for me!!!

Tran Manh Linh - Linhtm
linhtm.viss@gmail.com
linhtm@vietintelligences.com

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-09-24 : 22:25:51
HuH!!!!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-24 : 22:47:00
Basically nothing except the number of affected rows, (But if you use SET NOCOUNT ON then it will not return at all.) and also what ever you are specifing in the OUTPUT clause.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

dexter.knudson
Constraint Violating Yak Guru

260 Posts

Posted - 2008-09-25 : 01:47:11
If you inspect 2 system variables as the next statement after running your update, they will tell you any error code & the number of rows affected eg: SELECT @yourErrorVariable = @@error, @yourRowsAffectedVariable = @@rowcount
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-25 : 01:58:29
also if you use OUTPUT clause as Khtan suggested, you can return values before and after update from tables.

UPDATE Table1
SET Field1=value1,
Field2=value2....
OUTPUT DELETED.Field1,INSERTED.Field1,DELETED.Field2,INSERTED.Field2,...
FROM Table1
JOIN Table2
....


gives you values of fields in Table1 before and after UPDATE action.
Go to Top of Page

beliveinmyshelf
Starting Member

15 Posts

Posted - 2008-09-25 : 02:07:44
thank everybody

Tran Manh Linh - Linhtm
linhtm.viss@gmail.com
linhtm@vietintelligences.com
Go to Top of Page
   

- Advertisement -