omtechguy wrote:
> Hi,
>
> is there an option to get the identities of the affected rows and not
> only a counter that mention the number of the affected rows?
It depends on the version of SQL Server you are using. SQL 2008 introduced
the OUTPUT clause that you can read about here:
http://msdn.microsoft.com/en-us/library/ms177564.aspx
With earlier versions, you needed to create a trigger that selected the
contents of the temporary inserted table
(
http://technet.microsoft.com/en-us/library/ms191300.aspx), but of course,
that would fire for all update statements, not particular ones. Of courrse,
you could crate and then disable it, and for updates where you need to see
the affected rows, enable the trigger before running them, and disable it
after.
http://technet.microsoft.com/en-us/library/ms182706.aspx
>
> Another question, is there an (NOLOCK) equivalent option for update
> statement?
No. Of course not. This question is really fundamental and leads me to
suspect that you have not done your homework. At the very least, you should
get a book about SQL Server and read it, maybe one of Davidson's, or
Delaney's.
You could attempt to specify ROWLOCK, but that is the default, and if your
query affects too many rows, it will escalate to a table lock anyways.