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
 Transact-SQL (2000)
 Mismatch

Author  Topic 

coconnor
Starting Member

4 Posts

Posted - 2002-11-26 : 10:34:41
I am going around in circles and have a SQL question for you. I am trying to do an 'in' query where I have

A.respstaff_1 in (805963254,805962969)

where A.respstaff_1 is the type integer. The above works fine but as I need to pass this into the store procedure as '805963254,805962969' I get a type mismatch error. Do you have any ideas as to how I can convert '805963254,805962969' to 805963254,805962969?

Thanks in advance
Cheryl

mr_mist
Grunnio

1870 Posts

Posted - 2002-11-26 : 10:40:41
Do a forum search for the numerous threads on CSV...

-------
Moo.
Go to Top of Page

coconnor
Starting Member

4 Posts

Posted - 2002-11-26 : 10:47:07
quote:

Do a forum search for the numerous threads on CSV...

-------
Moo.



I am not sure what you mean by csv I am not creating a csv file I am want to search for more than one parameter in my where clause. Perhaps I did not make myself clear.

I am doing a store procedure with a big long list of where clauses. One of which I want to be in (134924,23823) but when I evoke the store procedure this is being handled as '134924,23823' which is giving me a type mismatch or cast error. I tried stripping out the ' but if I write this into a int parameter it is unhappy with the , and if I write it into a varchar2() it puts the ' back in.

Still stuck
Cheryl

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-11-26 : 10:51:40
mist is not suggesting CSV file, but rather CSV list. Put simply, you pass into your procs a Comma Seperated Value List of ints. In your proc, you parse that CSV and put each data value into a table. Then rather an IN construct in your WHERE clause, you do a INNER JOIN on you table of allowable values.

You can get to the same place using Dynamic SQL (search on that too) ... it's up to you to test both methods and decide which works better.

Jay White
{0}
Go to Top of Page

coconnor
Starting Member

4 Posts

Posted - 2002-11-26 : 10:59:11
I am actually doing this somewhere else where I use an user-defined function to create a table for a comma delimited list and then do a join to that table. But in this case it was not appropriate so I was hoping to use the in and put it in the where clase but if it is not possible I will go back to the table.

Thanks for your help
Cheryl

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-11-26 : 11:02:00
quote:
I was hoping to use the in and put it in the where clase but if it is not possible I will go back to the table.
It IS possible, if you read the dynamic SQL articles:

http://www.sqlteam.com/SearchResults.asp?SearchTerms=dynamic+sql

Go to Top of Page

coconnor
Starting Member

4 Posts

Posted - 2002-11-26 : 11:11:34
What a difference some help makes - within seconds I have it working - thanks very much for all your help!

Go to Top of Page
   

- Advertisement -