Counting the number of deleted rows in a SQL Server stored procedure

前端 未结 7 1714
借酒劲吻你
借酒劲吻你 2021-02-06 20:26

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

7条回答
  •  野性不改
    2021-02-06 21:11

    Create temp table with one column, id.

    Insert into temp table selecting the ids you want to delete. That gives you your count.

    Delete from your table where id in (select id from temp table)

提交回复
热议问题