Update values from one column in same table to another in SQL Server

后端 未结 8 876
忘了有多久
忘了有多久 2020-12-15 03:25

I\'m trying to overwrite values that are found in TYPE1 with values that are found in TYPE2.

I wrote this SQL to try it out, but for some reason it isn\'t updating:<

相关标签:
8条回答
  • 2020-12-15 03:51

    This answer about updating column from a part of another column in the same table.

    update T1
    set domainname = (New value) --Example: (SELECT LEFT(TableName.col, CHARINDEX('@',TableName.col)-1) STRIPPED_STRING FROM TableName where TableName.col = T2.Emp_ID)
    from TableName T1
    INNER JOIN
        TableName T2
    ON 
        T1.ID= T2.ID;
    
    0 讨论(0)
  • 2020-12-15 03:53

    Your select statement was before the update statement see Updated fiddle

    0 讨论(0)
提交回复
热议问题