Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Spilt List Function Expand / Collapse
Author
Message
Posted Thursday, February 14, 2013 8:08 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 17, 2014 10:18 AM
Points: 10, Visits: 95
This must be much simplier than I'm making it...

I have an unique idenifier for a person, and a space delimited field containing grades they teach, since they could teach more than one grade I'm looking to have their unique idenifier and a single grade taught. I have a split list function but how do I do this...

SELECT ID,
(SELECT * FROM dbo.udfSplitList(Grades,' ')
FROM TableA

I know this is the wrong way and I get errors, any guidance would be great!

Thanks!
Post #1420099
Posted Thursday, February 14, 2013 8:13 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 11:02 AM
Points: 20,734, Visits: 32,497
eagb (2/14/2013)
This must be much simplier than I'm making it...

I have an unique idenifier for a person, and a space delimited field containing grades they teach, since they could teach more than one grade I'm looking to have their unique idenifier and a single grade taught. I have a split list function but how do I do this...

SELECT ID,
(SELECT * FROM dbo.udfSplitList(Grades,' ')
FROM TableA

I know this is the wrong way and I get errors, any guidance would be great!

Thanks!


First, you really should provide the details of the error(s) you are getting. It really doesn't tell us anything when all you say is "I get errors."

Second, it looks like dbo.udfSplitList is a table valued function. This is how you should be using it in this case:


SELECT
a.ID,
sl.* -- not sure what the column or columns returned are or I would list them.
FROM
TableA a
CROSS APPLY SELECT * FROM dbo.udfSplitList(Grades,' ') sl





Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1420104
Posted Thursday, February 14, 2013 8:30 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 17, 2014 10:18 AM
Points: 10, Visits: 95
Thank you that worked perfectly!
Post #1420118
Posted Tuesday, February 26, 2013 11:26 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 8:27 AM
Points: 35,349, Visits: 31,889
eagb (2/14/2013)
Thank you that worked perfectly!


Any chance of us getting a peek at your split function?


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1424344
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse