select * from table where field1 in @po就不可以,why?
select @po的值为
'aa','aa',bb'
select * from table where field1 in (@po)就不可以,why?
问题点数:20、回复次数:4Top
1 楼zsforever(虎虎)回复于 2003-08-02 00:19:26 得分 5
@po 会被认为是一个变量,而不是多个!Top
2 楼saucer(思归)回复于 2003-08-02 01:03:02 得分 10
use exec, for example
use pubs
go
declare @lastnames varchar(100)
SET @lastnames = '''white'',''green'',''carson'''
exec('select * from authors where au_lname in (' + @lastnames +')')Top
3 楼txlicenhe(马可)回复于 2003-08-02 09:01:59 得分 5
declare @po varchar(100)
set @po = '''aa'',''aa'',''bb'''
exec('select * from table where field1 in (' +@po + ')')Top
4 楼cgsun(colin)回复于 2003-08-02 22:12:41 得分 0
3qTop




