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.
| Author |
Topic |
|
vitc
Starting Member
3 Posts |
Posted - 2006-02-12 : 18:12:55
|
| I am creating a sql function that will use a cursor to generate a list of email addresses based on a supplied list of table identities. This is returned in a query to coldfusion. Problem is the @ListofIdents in the function has to be varchar datatype and the identities are numeric. So I don't know how to do this:WHERE Ident IN ( @ListofIdents )for example:WHERE Ident IN ( 180,181,190 )Been a long day so I maybe missing the obvious! Help!! Thanks. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-02-12 : 18:29:31
|
| where ',' + @ListofIdents + ',' like '%,' + convert(varchar(20),Ident) + ',%'==========================================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. |
 |
|
|
vitc
Starting Member
3 Posts |
Posted - 2006-02-12 : 18:39:06
|
YOU ROCK!!! Thanks so much - one quick question ( though it won't be an issue for my problem, but for future knowledge).What would happend by chance with this list:18,20And the database had these identities:18,20,180,200Would it return the emails of ident 18,20 AND 180,200?? Since the LIKE statment.Again thanks... |
 |
|
|
vitc
Starting Member
3 Posts |
Posted - 2006-02-12 : 18:48:22
|
| Ok, worked out the logic on paper and I think the answer to my question is no. Cool... |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-02-12 : 19:17:57
|
If you are going to use dynamic SQL, you could just do this:exec ( 'select * from Mytable WHERE Ident IN ('+@ListofIdents+')' )CODO ERGO SUM |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|