Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 using single and double QUOTED

Author  Topic 

CLages
Posting Yak Master

116 Posts

Posted - 2005-01-07 : 11:36:15
hi , this script works well, but if i use using the comment line
i get nothing
where is my mistake
Tks
Carlos Lages



SET QUOTED_IDENTIFIER OFF

declare @tpfat char(200)

set @tpfat = "'601', '701'"

SELECT * FROM MOVIMENT WHERE
MOV_TPFATURA IN ('601', '701')
--MOV_TPFATURA IN (@tpfat)

nr
SQLTeam MVY

12543 Posts

Posted - 2005-01-07 : 11:52:33
@tpfat is a single string so your test is actually an =.

' is a string delimitter not "
set @tpfat = '''601'', ''701'''


declare @tpfat varchar(20)
set @tpfat = '''601'', ''701'''
declare @sql varchar(1000)
select @sql = 'SELECT * FROM MOVIMENT WHERE MOV_TPFATURA in (' + @tpfat + ')'
exec (@sql)




==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

CLages
Posting Yak Master

116 Posts

Posted - 2005-01-07 : 11:53:07
I saw in BOL that i can only use CONSTANT in the expression IN
but in this case how can i use IN , in a Stored Procedure ?
In other words i need to pass '601, '701, etc into a String as parameter to the SP

because i can only pass variable as Parameter

how can i fix it

Tks again
C. Lages
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-01-07 : 12:04:44
see the code I posted.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -