日期:2014-05-18 浏览次数:20418 次
declare @i int set @i=0 declare @iCount int set @iCount=(select count(*) from @库表名) declare @fTableName nvarchar(50) while(@i <@iCount) begin set @i=@i+1 delete @库表名 where fID=@i) end
------解决方案--------------------
[code=SQL][/code]
CREATE PROCEDURE s_Delete
(
@库表名 table
)
declare @i int
set @i=0
declare @iCount int
set @icount= exec('select count(*) from '+@库表名)
while(@i <@iCount)
begin
set @i=@i+1
declare @fTableName nvarchar(50)
set @Name=exec('select Name from '+@库表名 +' where fID='+ltrim(@i))
exec('delete from ' +[@Name])
end