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 |
|
kbromwich
Starting Member
5 Posts |
Posted - 2005-06-30 : 23:07:35
|
| okay i have a comma sperated list of guids in a string in that is passed to the database.now i know that if i do the following i can get them to format properly and run if i use the execute (sql).passed in value would look like this'b30fa6be-784d-4a3d-8902-2547c3821cc3,de34fd53-3077-470c-80bc-d9c3d3a83436,f2354569-8d2a-4a3f-8840-9fcabb9405f5'SELECT @IDs = '''' + REPLACE(@IDs , ',', '''' + ',' + '''') + ''''so i get the string 'guid','guid' etc.and would then use it like this.set @strsql = 'select value from table where id in (' + @ids + ')'execute (@strsql)now is there a way of getting this format to work properly with out using the execute.i want to have a function, and well the function does not seem to behave properly with an execute in itso i want for example select value from table where ids in (@ids) using the list that would be passed as above. at the moment it works sort of only for the first guid in the list. the others are ignored.hopefully there is enough for everyone to work with |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-07-01 : 01:27:02
|
There are examples on SQL Team of SQL functions that will "split" a comma delimited list, and return it as a table. Then you can just JOIN that output:select valuefrom table JOIN dbo.MySplitFunction(@ids) ON MyFunctionReturnID = id Kristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|