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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-09-22 : 07:36:22
|
| Rasmus writes "HiI basically trying to do the following:Select * from sometable where id in ( ... ) where the id should be an uniqueidentifier (Guid).The problem is that I'm calling the stuff through a stored procedure.In my query analyzer I can just do the following: ... IN ( '04577974-ea03-4442-a293-47cecd947060', '852bd23f-e051-4192-ab7d-70622f0e2d4f' )The problem is that when sending the list of IDs to the database I'm sending them in one variable:@IDs VARCHAR( 8000 ) -- ok limiting me to aprox 200 ids(but wait, that's not all ;o)The real problem is when I'm sending the sp through some C# code, the query gets translated to '''04577974-ea03-4442-a293-47cecd947060'', ''852bd23f-e051-4192-ab7d-70622f0e2d4f''' (when using ' to enclose the guids)If I use { to enclose the guids the @IDs var ends up looking like this '{04577974-ea03-4442-a293-47cecd947060}, {852bd23f-e051-4192-ab7d-70622f0e2d4f}' (one long string)and the query doesn't find anything...I can pretty much find my way in standard sql, but haven't used much stored procedures. Perhaps I could send an array to the sp?! But I haven't used arrays in sql enviroments before, how could this look?!RegardsRasmus" |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-09-22 : 07:58:33
|
| No such thing as an array in sql.The string you have is ok. You can then parse it to split it into the individual guids for the join.Easiest to create a table valued function to do this and join to that==========================================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. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-09-22 : 08:01:34
|
| Check out this article:http://www.sqlteam.com/item.asp?ItemID=11499there's a few good threads here as well that discuss all of this in detail .... search for CSV and UDF ... (CSV = comma separated values)- Jeff |
 |
|
|
|
|
|