Forem

bikashgosai
bikashgosai

Posted on

Update bulk data in second table's one column based upon first table's another column's data which has multiple condition MSSQL

UPDATE table2
SET column2 = 
  CASE 
    WHEN table1.column1 = 'condition 1' THEN 'new value 1'
    WHEN table1.column1 = 'condition 2' THEN 'new value 2'
    WHEN table1.column1 = 'condition 3' THEN 'new value 3'
    ELSE table2.column2
  END
FROM table2 
JOIN table1 ON table2.some_column = table1.some_column
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay