SELECT a String

  • Hi I have string as below:

    InvoiceTemplateId= SOURCE.InvoiceTemplateId

    ,Name= SOURCE.Name

    ,DetailTotalUnitsQty= SOURCE.DetailTotalUnitsQty

    ,InsertedDate= SOURCE.InsertedDate

    ,UpdatedDate= SOURCE.UpdatedDate

    ,Distributor_Id= SOURCE.Distributor_Id

    ,InsertedBy= SOURCE.InsertedBy

    ,UpdatedBy= SOURCE.UpdatedBy

    I need a string Like below:

    Name= SOURCE.Name

    ,DetailTotalUnitsQty= SOURCE.DetailTotalUnitsQty

    ,InsertedDate= SOURCE.InsertedDate

    ,UpdatedDate= SOURCE.UpdatedDate

    ,Distributor_Id= SOURCE.Distributor_Id

    ,InsertedBy= SOURCE.InsertedBy

    ,UpdatedBy= SOURCE.UpdatedBy

    So I need every thing except the First value before first comma . So could some one help in TSQL .. Thanks in Advance

  • I'm leaving 3 possible options. Please don't cross post as it will only fragment the answers.

    SELECT String,

    STUFF( String, 1, CHARINDEX( ',', String), ''),

    SUBSTRING( String, CHARINDEX( ',', String) + 1, 8000),

    RIGHT( String, LEN(String) - CHARINDEX( ',', String))

    FROM ( VALUES(

    'InvoiceTemplateId= SOURCE.InvoiceTemplateId

    ,Name= SOURCE.Name

    ,DetailTotalUnitsQty= SOURCE.DetailTotalUnitsQty

    ,InsertedDate= SOURCE.InsertedDate

    ,UpdatedDate= SOURCE.UpdatedDate

    ,Distributor_Id= SOURCE.Distributor_Id

    ,InsertedBy= SOURCE.InsertedBy

    ,UpdatedBy= SOURCE.UpdatedBy'))x(String)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply