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 2000 Forums
 Transact-SQL (2000)
 Number of Rows

Author  Topic 

ramdas
Posting Yak Master

181 Posts

Posted - 2004-02-06 : 08:48:41
Hi Folks,
I want to perform a audit on the result of the following statement

DECLARE @row_cnt int
DELETE FROM table_a --I want to capture number of rows deleted
IF @@ERROR=0
SELECT 'Number of Rows Deleted :'+convert(varchar,@row_cnt)

Where will i set the variable @row_cnt=@@ROWCOUNT, i cannot do it inside the IF because the value of @@rowcount will be reset. In a nut shell, if the delete operation succeeds i want to report the number of rows deleted.

Ramdas




Ramdas Narayanan
SQL Server DBA

nr
SQLTeam MVY

12543 Posts

Posted - 2004-02-06 : 09:26:25
DECLARE @rowcount int, @error int
DELETE FROM table_a --I want to capture number of rows deleted
select @error = @@error, @rowcount = @@rowcount
IF @error=0
SELECT 'Number of Rows Deleted :'+convert(varchar,@rowcount)

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

ramdas
Posting Yak Master

181 Posts

Posted - 2004-02-06 : 09:41:18
Thank you
Ramdas

Ramdas Narayanan
SQL Server DBA
Go to Top of Page
   

- Advertisement -