@@Rowcount with Truncate
Aug 10 2012 12:00AM by Jeetendra@@ROWCOUNT returns the number of affected rows by last statement. Below example illustrate the same
1.CREATE TABLE #t (id int)2.INSERT INTO #t(id) values(1)3.DELETE #t4.SELECT @@ROWCOUNTBut same did not work for truncate
1.CREATE TABLE #t (id int)2.INSERT INTO #t(id) values(1)3.TRUNCATE table #t4.SELECT @@ROWCOUNTIt is because truncate removes page allocation not as individual row, so it will not return row count value.
one important point is, if number of affected row is more then 2 billion, we need to use rowcount_big.
No comments:
Post a Comment