双叶草学习室

 

一段用于清空数据库中所有的用户表的SQL语句

declare crsr insensitive cursor
for SELECT [name] FROM DBO.SYSOBJECTS
WHERE OBJECTPROPERTY(ID,N'IsTable')=1 and type = 'U' and [name] <> 'dtproperties' and [name]<> 'SpecialityInfo' and [name]<> 'ApplyRegInfo'--and crdate...
for read only
open crsr
declare @tblName sysname
fetch next from crsr into @tblName

while (@@fetch_status<>-1)
begin
EXEC('truncate table '+@tblName)
print('truncate table '+@tblName)
fetch next from crsr into @tblName
end
close crsr

deallocate crsr --删除以释放游标

 

 

posted on 2009-04-22 11:27  双叶草人  阅读(135)  评论(0)    收藏  举报

导航