Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Type Convertion 1

Status
Not open for further replies.

jerasi

Programmer
Jun 19, 2000
141
CA
I have a stored procedure that gets a parameter @IDsList, @IDsList is a varchar(1000) and it holds a list of IDs i.e. '1,2,3,4,5,6'
I would like to be able to use this list in this query:
Select stuff
From sometable where iID in (@IDsList)
But, I get this error: Syntax error converting the varchar value '1,2,3,4,5,6' to a column of data type int.

How can I do this?

Thank you.
 
Hi,

Try this
Declare @SQL varchar(3000)

SET @SQL = 'Select stuff
From sometable where iID in (' + @IDsList +' )'

exec(@SQL)

Sunil
 
Hi Terry,

I will create an FAQ on this.

Thanks

Sunil
 
Hi,

I have just created a FAQ on this issue.

Executing Dynamically Created T-SQL Strings
faq183-3132

Please inform me of any additions,suggestion or modifications to the FAQ

Thanks

Sunil

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top