例如这个查询语句,
(select Id from VideoType where tid in
(select Id from VideoType where tid in
(select Id from VideoType where tid in
(select Id from VideoType where tid in
(select id from VideoType where tid in(select id from VideoType where Title in('老人专区','幼儿专区')))))))
我能不能这样
string a="(select Id from VideoType where tid in";
然后查询语句就瘦身了变成
a
a
a
a
a "in(select id from VideoType where Title in('老人专区','幼儿专区')))))))"
请问该怎么实现?
set @sql = " select * from TableName";
exec ( @sql);追问
能详细点吗?怎么连接他们
这样吗?
declare @sql nvarchar(max);
set @sql = '(select Id from VideoType where tid in'
exec (@sql)+
exec(@sql)+(select id from VideoType where Title in('老人专区','幼儿专区')))))))))
能详细点吗?怎么连接他们
这样吗?
declare @sql nvarchar(max);
set @sql = '(select Id from VideoType where tid in'
exec (@sql)+
exec(@sql)+(select id from VideoType where Title in('老人专区','幼儿专区')))))))))
1、先拼接完 @sql
2、最后调用 exec (@sql) ;
--
不过,你得确保你写的sql没有问题