日期:2014-05-18 浏览次数:20612 次
select * from sysobjects where id in (select id from syscolumns where name= 'approvedate')
declare @k datetime declare @j datetime set @k='2009-04-20 10:10:11.000' set @j='2009-04-23 19:53:11.000' delete FROM RegisterReport WHERE approveDate BETWEEN @k AND @j;
declare @k datetime declare @j datetime set @k='2009-04-20 10:10:11.000' set @j='2009-04-23 19:53:11.000' --delete FROM RegisterReport --WHERE approveDate --BETWEEN @k AND @j; --生成语句直接执行 select ' delete 'a.+name+' where approvedate between '''+CONVERT(varchar(23),@k,120)+''' and '''+CONVERT(varchar(23),@k,120)+''' ;' from sysobjects as a,syscolumns as b where a.id=b.id and b.name='approvedate' --或用变量传参一次执行 declare @s nvarchar(max) select @s=@s+' delete '+a.name+' where approvedate between '''+CONVERT(varchar(23),@k,120)+''' and '''+CONVERT(varchar(23),@k,120)+''' ;' from sysobjects as a,syscolumns as b where a.id=b.id and b.name='approvedate' exec(@s)