use emsb7_test1023 declare@namevarchar(140) declare ##cursorcursorforselect name from emsb7_test1023.dbo.sysobjects where xtype=\'U\' open ##cursor fetchnextfrom ##cursorinto@name while@@fetch_status=0 begin exec(\'truncate table \'+@name)
----少些一句:fetchnextfrom ##cursorinto@name从而陷入了死循环 end close ##cursor deallocate ##cursor
use emsb7_test1023 declare@namevarchar(140) declare c cursorforselect name from emsb7_test1023.dbo.sysobjects where xtype=\'U\' open c fetchnextfrom c into@name while@@fetch_status=0 begin exec(\'truncate table \'+@name) fetchnextfrom c into@name end close c deallocate c