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)
 Problem with stored procedure - WHERE IN statement

Author  Topic 

rocklinzc
Starting Member

7 Posts

Posted - 2003-02-13 : 16:26:51
Hello,
I have a Select statement that looks like:
SELECT * FROM CAT_TABLE WHERE CAT_ID IN (3, 7, 12, 19, 23)

This works fine, but when I use a variable in a stored procedure like so:
SELECT * FROM CAT_TABLE WHERE CAT_ID IN (@CatList)

I get a nasty error (Error converting the varchar value '3, 7, 12, 19, 23' to a column of datatype int)

Is there anyway around this?

Thanks for your help



Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-02-13 : 16:29:50
Hi

Do some forum searching for the term CSV and you should find a bunch of solutions to this.

Damian
Go to Top of Page

rocklinzc
Starting Member

7 Posts

Posted - 2003-02-13 : 17:12:14
thanks, i found a lot of topics on this situation and i am trying to use the User Defined Function located here: http://www.sqlteam.com/item.asp?ItemID=11499

But when I run the Stored Procedure I get "Invalid object name 'dbo.CsvToInt'."

I am running SQL Server 2000 in case that matters.

Any ideas?

Thanks



Edited by - rocklinzc on 02/13/2003 17:12:43
Go to Top of Page

rocklinzc
Starting Member

7 Posts

Posted - 2003-02-13 : 17:17:41
I figured it out I just had part of the select * from dbo.csvtoint() wrong.

Thanks for you help!

Go to Top of Page
   

- Advertisement -