sqlserver里如何传递 in参数
select *
from table1
where usercode in(@Usercodes)
传入的参数@Usercodes = ’code1‘,’code02‘
这样是不行的。SQL不支持者样做。
(1)通过拼接 SQL 最后去 exec (@sql)来实现: ’。。。where usercode in('+@Usercodes+') '
(2)通过: select * from table1 where charindex(','+rtrim(usercode )+',' , ','+ @Usercodes +',')>0 来实现。这里
@userCode = code1,code2 (没有用单引号包括起来)
诗词在线
http://www.chinapoesy.com
诗词在线 |唐诗|宋词|元曲|现代诗歌|外国诗歌
126在线阅读网
http://www.Read126.cn
126在线阅读网 人物传记、古典名著、历史书籍。。。
http://www.chinapoesy.com
诗词在线 |唐诗|宋词|元曲|现代诗歌|外国诗歌
126在线阅读网
http://www.Read126.cn
126在线阅读网 人物传记、古典名著、历史书籍。。。