|
|
Question : T-SQL - Insert Column If True
|
|
Select a.Column1 b.Column2 From Tbl1 a Tbl2 b Where a.Column1 = b.Column1
If Column1 exists in Tbl2 I just want b.Colmun2 to = 'T', otherwise 'F'. Taking away the statement above, basically, I just want to display a T or F column in the result if data exists in Tbl2. Thanks.
|
Answer : T-SQL - Insert Column If True
|
|
Try:
select a.column1, case when exists (select * from tbl2 b where a.column1=b.column1) then 'T' else 'F' end as column2 from tbl1 a
Cheers,
|
|
|
|
|