Update Help

  • I have a value in a table is 111-000-000070G and i have to update this as G111000000070, is there any way to this with single statement (ofcourse i need to update bunch of records).

    Thanks,

  • Is the last character of the string always what you want at the beginning? If so try something like the following.

    UPDATE Foo

    SET fld = RIGHT(fld,1) + LEFT(REPLACE(fld,'-',''), LEN(REPLACE(fld,'-',''))-1)

    I don't have SQL installed at home so I can't test this and don't have SQL Books Online to verify my syntax but it should be close!




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

  • Thanks, it worked.

     

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

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