Solved

SQL Split output

Posted on 2016-10-25
2
25 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:
ScottPletcher 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now