如何实现动态sql清空数据库表
如何实现动态sql清空数据库表
数据库 basedata
table:tblwodefinition 中字段 :MasterTableName 下: a b c ....
------解决方案--------------------declare @sql varchar(1000)
declare @tbl varchar(200)
declare hyc cursor
local
for select name from sysobjects where objectproperty(object_id(name), 'IsUserTable ')=1
open hyc
while @@fetch_status=0
begin
fetch next from hyc into @tbl
set @sql= 'drop table ' + @tbl
exec(@sql)
end
close hyc
deallocate hyc