I have two tables and i am using a simple join condition between them.
I need to find the common values and updated the String(Success) into the column.
input_table1:
ID || Name || output
1 || ABS || Null
2 || ADF || NULL
3 || AQS || Null
4 || ATF || NULL
5 || APS || Null
6 || AMF || NULL
ID || Name
1 || ABS
2 || ADF
6 || AMF
ID || Name || output
1 || ABS || Success
2 || ADF || Success
3 || AQS || Null
4 || ATF || NULL
5 || APS || Null
6 || AMF || Success.
update .[dbo].[InputTable1]
set Output=
case when (
select INT.ID
from [dbo].[input_table1] INT
join [dbo].[input_table2] SHB
on INT.ID=SHB.ID
) Then 'Success' Else Null End
your query should simply be
update INT
set Output= 'Success'
FROM
[dbo].[input_table1] INT
join [dbo].[input_table2] SHB
on INT.ID=SHB.ID