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
 General SQL Server Forums
 New to SQL Server Programming
 Comma separated value

Author  Topic 

Access
Starting Member

44 Posts

Posted - 2007-06-26 : 15:38:18

I’m passing a comma separated parameter (home, world, child) into stored procedure.
I have a Slitter function which is basically creates a table out of delimited list.

My stored procedure needs to find matched records in one of the table based on delimited list.

I have something like this:

SELECT *
FROM Word
WHERE WordName IN (SELECT * FROM dbo.fxSplitter('home,world,child, ',')

I would like to have my stored procedure be able to select rows, even if comma delimited parameter holds part of the name like this “hom, wor, chil” .
Another words it will be SELECT * FROM Word WHERE WordName LIKE '%hom%' OR WordName LIKE '%wor%' OR WordName LIKE '%chil%'

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-06-26 : 15:51:39
I don't know how your function works, but something like:

SELECT Word.*
FROM Word
INNER JOIN dbo.fxSplitter('home,world,child', ',') x
on Word.WordName like '%' + x.FunctionColumnName + '%'

I put "FunctionColumnName" in there because I have no idea what column name is returned from your function, since you don't specify in your example.


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

Access
Starting Member

44 Posts

Posted - 2007-06-26 : 16:00:01
quote:
Originally posted by jsmith8858

I don't know how your function works, but something like:

SELECT Word.*
FROM Word
INNER JOIN dbo.fxSplitter('home,world,child', ',') x
on Word.WordName like '%' + x.FunctionColumnName + '%'

I put "FunctionColumnName" in there because I have no idea what column name is returned from your function, since you don't specify in your example.


- Jeff
http://weblogs.sqlteam.com/JeffS




That did it, thanks a lot.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-27 : 00:11:54
More stuffs on handling csv
http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -