Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
nirnir
Starting Member
10 Posts |
Posted - 2013-10-16 : 05:53:39
|
I have two tables TableA key :char[20] data:char[100]TableB kay :char[20] existInTableA : bitI need to update existInTableA field in each record of tableBto indicate if tableA contains record with same keywhat is the best way to do that ?attached sample data TableA-----------key1,data1key2,data2key4,data4TableB----------key1,truekey2,truekey3,falsekey4,true |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-16 : 08:01:27
|
[code]UPDATE bSET existInTableA = 1FROM TableB bWHERE EXISTS (SELECT 1 FROM TableA WHERE key = b.key)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|