Update Query for same table in 2 different column

  • Hi,

    Thanks for advance,

    I have one small question i have one table like 2 columns both are varchar(250),Actually i wanted to update 1 field values to other one,Below this mention more describtion.

    Table field Example :

    Nameplace(

    Firstname Varchar(250),

    Lastname Varchar(250)

    )

    Table Example data :

    FirstName Lastname

    TestingFields TestingAverage

    TestingSum TestingIncremnt

    I wanted to fetch Lastname fields get the last 3 character replace firstname field.

    Please share some example query.

    Thanks

  • im getting a little confused, can you post DDL Sample Data and the expected output based on that sample data?? it would really help to have both the input and the desired output.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]

    Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
    Jeff Moden's Cross tab and Pivots Part 1[/url]
    Jeff Moden's Cross tab and Pivots Part 2[/url]

  • If you want to update the first column so that it's the last 3 characters of the second column, it would look like this:

    Update dbo.MyTable

    set Col1 = right(Col2, 3);

    Is that all you're trying to do?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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