Sql 语句中的问号
这是我的疑问:Sql 语句中的问号,sql,Sql,这是我的疑问: select top 6 Nr,'<a href=[url]?id=' + convert(varchar,Nr) + '&ch=TRA&channel=TRA>' + isnull(menutitle,title) + '</a>' as title from vwActive where NR IN (select nr from dbo.fn_RecurseChildren(
select top 6 Nr,'<a href=[url]?id=' + convert(varchar,Nr) + '&ch=TRA&channel=TRA>' + isnull(menutitle,title) + '</a>' as title
from vwActive
where NR IN (select nr from dbo.fn_RecurseChildren('4',0))
and parent not in (6985,54092,29,28,98086,97126)
and Nr not in (?)
and isnull(ShowFrom,AddDate) >=(getdate()-14)
and contentType<>7
and hiddenchild=0
and (Body NOT LIKE '' AND Body NOT LIKE '<P> </P>'
or Description NOT LIKE '' AND Description NOT LIKE '<P> </P>'
)
and nr not in(
select replace(ctspecificvar1,char(91)+'item'+char(93)+'=','') link
from vwactive
where hiddenchild=0 and parent=6985
and contenttype=7
and isnumeric(replace(ctspecificvar1,char(91)+'item'+char(93)+'=',''))=1
)
and nr not in (
select case when isnumeric(replace(ctspecificvar1, '[item]=', '')) = 1 then convert(int,replace(isnull(ctspecificvar1, 0), '[item]=', '')) else 0 end link
from vwActive
where contenttype=7 and hiddenchild=0 and parent=6985
)
但是如果我省略了那句话,那么查询就可以工作了
但是如何让查询与语句一起工作:
and Nr not in (?)
而Nr不在(?)
谢谢你问号应该用参数填充,也就是说,替换为一个应该被查询排除的数字列表 因此,如果您不介意,只需删除该行(或使用“---”将其注释掉)
如果您愿意,请将Nr值放在要排除的位置。您希望(?)中的
为您做什么?您得到的错误消息是什么?为什么查询中有这一行?SQL的味道是什么?问号是动态SQL中的参数标记。即准备语句、提供输入参数并执行语句。