Solved

SQL Split output

Posted on 2016-10-25
2
39 Views
Last Modified: 2016-10-25
Hi I have a column in Microsoft SQL 2008 that it data is delimited by a "."   every column has it and only one delimiter

so I have  something like this

RecordID ,  TableFieldName
-------------   -----------------------------------
1                 Profile.Firstname
2                 Profile.LastName
3                 Contact.PhoneNumber

I would want to have output like this

Record    Table            Field
----------    -------------    ----------------------
1              Profile          FirstName
2              Profile          LastName
3              Contact        PhoneNumber
0
Comment
Question by:charlesbaldo
2 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 500 total points
ID: 41859075
SELECT
    RecordID,
    LEFT(TableFieldName, CHARINDEX('.', TableFieldName) - 1) AS Table,
    SUBSTRING(TableFieldName, CHARINDEX('.', TableFieldName) + 1, 200) AS Field
FROM table_name
0
 

Author Closing Comment

by:charlesbaldo
ID: 41859197
Perfect Thank you
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question