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)
 convert from varchar to an int aray

Author  Topic 

Shunpanpan
Starting Member

1 Post

Posted - 2003-05-06 : 10:33:20
I have the following problem :
In a stored procedure I GET A VARCHAR e.g. @countriesList = '1,2,3,4,5,6,7,8'
I would like to use this VARCHAR somehow in the where clause e.g.
 Where ID_Country in @countriesList 

But you see.... the id_Country is an integer and these whole @countriesList is varchar, and of course the error statres that the varchar cannot be converted to integer. Do you know by any chance what can i do ?



Edited by - merkin on 05/06/2003 10:39:23

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-05-06 : 10:38:17
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25830

be sure to read the ENTIRE thread ... your problem is more than just a conversion problem, it is how you are trying to use the IN operator.

- Jeff
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-05-06 : 10:44:37
Yeah,

That was a hell of a thread...bunch of great stuff in it.

Definetly will solve your problem...

UDF...UDF...UDF...



Brett

8-)
Go to Top of Page

sgpkalle
Starting Member

7 Posts

Posted - 2003-05-06 : 12:57:56
TO ALL THE MILLIONS OF GUYS WHO WANT TO HELP THIS MAN:

I'm sitting opposite to him on the desk. We share the problem.

The command he wrote into the posting was wrong - we know. sorry!
so once again:

we try: WHERE ID-Country IN(@parameter)
@parameter is a varchar. it can include stuff like '2, 5, 3' or '99, 234). of course SQL cannot convert (@parameter) to bit.
does anyone know if SQL can convert the varchar to a list of parameters or if the IF-command can be modified to read teh varchar?



Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-05-06 : 13:02:43
Yeah, check out the thread Jeff posted...

did I say "great thread"?



Brett

8-)
Go to Top of Page
   

- Advertisement -