IN声明中的问号

时间:2015-09-21 13:02:55

标签: 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('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>&nbsp;</P>' 
                  or Description NOT LIKE '' AND Description NOT LIKE '<P>&nbsp;</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不在(?)

谢谢

1 个答案:

答案 0 :(得分:2)

问号应该填充参数,即替换为应该被查询排除的数字列表。

因此,如果您不在乎,只需删除该行(或使用“ - ”将其注释掉)。

如果您在意,请在其中输入要排除的Nr值。