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

some one write query for this problem Expand / Collapse
Author
Message
Posted Thursday, March 28, 2013 4:17 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, June 5, 2014 2:51 AM
Points: 41, Visits: 227
I have a table that contain a row

table name = PMInfo

pmid,member
1, jay-raj-kit

i want output like that
1 , jay
1 , raj
1, kit


Regards
Arjun.
Post #1436364
Posted Thursday, March 28, 2013 4:27 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 8:31 AM
Points: 2,661, Visits: 4,734
You can use the DelimitedSplit8K function for your requirement

SELECT	PMI.pmid, DS.Item
FROM PMInfo AS PMI
CROSS APPLY dbo.DelimitedSplit8K( PMI.member, '-') AS DS

The code for the function is present in the article by Jeff Moden below
http://www.sqlservercentral.com/articles/Tally+Table/72993/



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1436370
Posted Thursday, March 28, 2013 4:53 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, June 5, 2014 2:51 AM
Points: 41, Visits: 227
Hello Kingston Dhasian,

I have tried this query but it has show error "Invalid column name DS.ITEM".
I have converted this query as my table structure.

Regards,
Arjun
Post #1436383
Posted Thursday, March 28, 2013 5:36 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:44 AM
Points: 6,750, Visits: 13,898
writearjun53 (3/28/2013)
Hello Kingston Dhasian,

I have tried this query but it has show error "Invalid column name DS.ITEM".
I have converted this query as my table structure.

Regards,
Arjun


You will need to a) read the article b) create the function.


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1436405
Posted Thursday, March 28, 2013 6:51 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, June 5, 2014 2:51 AM
Points: 41, Visits: 227
Yes I have read article and found the solution

Thanks all.


Regards,
Arjun
Post #1436446
Posted Thursday, March 28, 2013 8:05 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:59 PM
Points: 13,007, Visits: 12,426
writearjun53 (3/28/2013)
Yes I have read article and found the solution

Thanks all.


Regards,
Arjun


Chris forgot about step c) Understand the code. This is important because it is you that has to support it.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1436481
Posted Thursday, March 28, 2013 8:26 AM


SSC-Insane

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

Group: General Forum Members
Last Login: Yesterday @ 7:58 PM
Points: 20,705, Visits: 32,356
writearjun53 (3/28/2013)
Yes I have read article and found the solution

Thanks all.


Regards,
Arjun


You say you found the solution, forum etiquette would have you share your solution for others.



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 #1436500
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse