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 |
|
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2007-04-28 : 16:09:42
|
| I need to search a field that has comma seperated values. So I am passing in a seperated values "1,3,6" and I need to search a comma seperated field. How do I do that? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-04-28 : 16:18:40
|
| use like.where youCSVColumn like '%' + @yourinputVariable + '%'_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2007-04-28 : 16:35:26
|
But what happens if you have a 1,12 and search for a 1. Don't you get both.quote: Originally posted by spirit1 use like.where youCSVColumn like '%' + @yourinputVariable + '%'_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp
|
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-04-28 : 17:33:40
|
| ok first of all:This is not a normalized database. It should be. you can use:select @yourinputVariable = '%,' +@yourinputVariable + ',%'select ...from ...where ',' + yourCSVColumn + ',' like @yourinputVariable_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
Kristen
Test
22859 Posts |
|
|
|
|
|