use 你要清空的库 go declare@tbnamevarchar(250) declare #tb cursorforselect name from sysobjects whereobjectproperty(id,'IsUserTable')=1 open #tb fetchnextfrom #tb into@tbname while@@fetch_status=0 begin exec('delete from ['+@tbname+']') fetchnextfrom #tb into@tbname end close #tb deallocate #tb
use 你要清空的库godeclare @tbname varchar(250)declare #tb cursor for select name from sysobjects where objectproperty(id,IsUserTable)=1open #tbfetch next from #tb into @tbnamewhile @@fetch_status=0begin