插入虚拟表
declare @indextable table(id int identity(1,1),nid int)
insert into @indextable(nid) select newsid from wqnews where heading like '% '+@skey+ '% ' order by addtime desc
这是原句,可以通过的,现在的问题是,因为后面的where条件是不确定的,故用了动态@sql
然后这句话怎么写?
declare @indextable table(id int identity(1,1),nid int)
exec( 'insert into @indextable(nid) select newsid from wqnews '+@sql)
这样写是肯定错误的,哪位能告知这句话怎么写不?
万分感谢
------解决方案----------------------update
exec( 'declare @indextable table(id int identity(1,1),nid int)
insert into @indextable(nid) select newsid from wqnews '+@sql)
------解决方案--------------------WangZWang(先来)
----正解