Jump to content

SQL server query help...


Rabbo

Recommended Posts

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

Link to comment
Share on other sites

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.

  • Haha 1
Link to comment
Share on other sites

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 .  

  • Like 1
Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 !

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...