?
Solved

SQL Split output

Posted on 2016-10-25
2
Medium Priority
?
59 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:Charles Baldo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 2000 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:Charles Baldo
ID: 41859197
Perfect Thank you
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

752 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