Rabbo Posted August 27, 2019 Report Posted August 27, 2019 struggling with sql server sql syntax i have 2 tables select id1, id2, end_dt from table A select id 1, id2 from table b i want to update a.end_dt to todays date if id1, id2 does not exist in table b Quote
Variety_Pullayya Posted August 27, 2019 Report Posted August 27, 2019 nee bondha. nuvvu em try chesavu cheppu first. people can correct if needed. just dont ask for people to write stuff for you. btw ...asalu both ids undakudada...okati unte saripothunda...ilanti info ivvakapothe asalu query ela rastharu. 1 Quote
Sarvapindi Posted August 27, 2019 Report Posted August 27, 2019 Use merge on id1 n id2 ..when not matchung update end date... check merge statements syntax Quote
Paidithalli Posted August 27, 2019 Report Posted August 27, 2019 Join use chey... assal nuvvu Adige question ardham katle Quote
kichikamukavu Posted August 27, 2019 Report Posted August 27, 2019 update a set end_dt =getdate() from table_A a left join table_B b on a.id1=b.id1 and a.id2=b.id2 where b.id1 is null assuming id1 and id2 are not null columns in table_B . 1 Quote
Rabbo Posted August 27, 2019 Author Report Posted August 27, 2019 update table A set end_dt=CAST(GETDATE() AS DATE) from table A and not exists (select A.* from table A, table B where a.id1=b.id1 and a.id2=b.id2) nenu rasindhi idhi, but not working Quote
Rabbo Posted August 27, 2019 Author Report Posted August 27, 2019 4 minutes ago, kichikamukavu said: update a set end_dt =getdate() from table_A a left join table_B b on a.id1=b.id1 and a.id2=b.id2 where b.id1 is null assuming id1 and id2 are not null columns in table_B . idhi try chesta Quote
Rabbo Posted August 27, 2019 Author Report Posted August 27, 2019 16 minutes ago, kichikamukavu said: update a set end_dt =getdate() from table_A a left join table_B b on a.id1=b.id1 and a.id2=b.id2 where b.id1 is null assuming id1 and id2 are not null columns in table_B . this worked bro, Thanks ! Quote
VinPetrol Posted August 27, 2019 Report Posted August 27, 2019 update a set end_dt =getdate() from table_A a left join table_B b on a.id1=b.id1 and a.id2=b.id2 where b.id1 is null and b.ID2 is null -- kuda add cheyali anukunta Quote
Rabbo Posted August 27, 2019 Author Report Posted August 27, 2019 10 minutes ago, VinPetrol said: update a set end_dt =getdate() from table_A a left join table_B b on a.id1=b.id1 and a.id2=b.id2 where b.id1 is null and b.ID2 is null -- kuda add cheyali anukunta emo bro, eh lavdalo sql server update ki work avthundhi same thing select ante work avatledu select a.id1, a.id2 from table_A a left join table_B b on a.id1=b.id1 and a.id2=b.id2 where b.id1 is null Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.