Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

How to update a table with if condition

$
0
0

here is my table 

Party1 party2 DELFlag

JON     NYC     0

JON     NYC1   0 

SAM     NYC   0

SAM    NYC1   0

TOM     NYC1   0

GIT      NYC1   0

No I need to change all NYC1 to NYC , but I get primary key error As JON is already related to JON->NYC  in this case I need to make the flag to 1 

To be more specific JON->NYC1 must be JON-NYC1-1 and TOM-NYC1-0 must change to TOM-NYC-0 as tom does not have any records 

My table update must look like 

Party1 party2 DELFlag

JON     NYC     0

JON     NYC1   1

SAM     NYC   0

SAM    NYC1   1

TOM     NYC   0

GIT      NYC   0


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>