From: Jami on

Dear All

sql 2000

i have following table

create table main_tab (Myid int, Status char(1))

Create table Sec_tab (Myid int, Report char(1))

i have following sample data in main_tab

insert into main_tab (myid) values (1)
insert into main_tab (myid) values (2)
insert into main_tab (myid) values (3)
insert into main_tab (myid) values (4)

i have following sample data in Sec_tab


insert into sec_tab values (1,'T')
insert into sec_tab values (2, 'S')
insert into sec_tab values (3, 'T')
insert into sec_tab values (4, 'T')

how can in a single update statement following will be achived status
in main_tab should be updated like status = 'Y'
when Report = 'T' and status = 'N' when Report = 'S'

Regards,
Jami










*** Sent via Developersdex http://www.developersdex.com ***
From: Uri Dimant on
UPDATE main_tab SET Status

=CASE WHEN Report='T' THEN 'Y'

WHEN Report='S' THEN 'N' END

FROM Sec_tab JOIN main_tab

ON main_tab.Myid=Sec_tab.Myid





"Jami" <jami.khan(a)yahoo.com> wrote in message
news:eC9xEC7BLHA.5848(a)TK2MSFTNGP06.phx.gbl...
>
> Dear All
>
> sql 2000
>
> i have following table
>
> create table main_tab (Myid int, Status char(1))
>
> Create table Sec_tab (Myid int, Report char(1))
>
> i have following sample data in main_tab
>
> insert into main_tab (myid) values (1)
> insert into main_tab (myid) values (2)
> insert into main_tab (myid) values (3)
> insert into main_tab (myid) values (4)
>
> i have following sample data in Sec_tab
>
>
> insert into sec_tab values (1,'T')
> insert into sec_tab values (2, 'S')
> insert into sec_tab values (3, 'T')
> insert into sec_tab values (4, 'T')
>
> how can in a single update statement following will be achived status
> in main_tab should be updated like status = 'Y'
> when Report = 'T' and status = 'N' when Report = 'S'
>
> Regards,
> Jami
>
>
>
>
>
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***