[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 62
  • Last Modified:

SQL Split output

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
Charles Baldo
Asked:
Charles Baldo
1 Solution
 
Scott PletcherSenior DBACommented:
SELECT
    RecordID,
    LEFT(TableFieldName, CHARINDEX('.', TableFieldName) - 1) AS Table,
    SUBSTRING(TableFieldName, CHARINDEX('.', TableFieldName) + 1, 200) AS Field
FROM table_name
0
 
Charles BaldoSoftware DeveloperAuthor Commented:
Perfect Thank you
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now