In SQL Server 2005, is there a way of deleting rows and being told how many were actually deleted?
I could do a select count(*)
with the s
I found a case where you can't use @@rowcount
, like when you want to know the distinct count of the values that were deleted instead of the total count. In this case you would have to do the following:
delete from mytable
where datefield = '5-Oct-2008'
output deleted.datefield into #doomed
select count(distinct datefield)
from #doomed
The syntax error in the OP was because output
did not include deleted
before the datefield
field name.