SQL如何把字符串赋值给变量,代替查询语句
例如这个查询语句,(selectIdfromVideoTypewheretidin(selectIdfromVideoTypewheretidin(selectIdfro...
例如这个查询语句,
(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('老人专区','幼儿专区')))))))"
请问该怎么实现? 展开
(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('老人专区','幼儿专区')))))))"
请问该怎么实现? 展开
展开全部
declare @sql nvarchar(max);
set @sql = " select * from TableName";
exec ( @sql);
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('老人专区','幼儿专区')))))))))
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询