Friday, April 17, 2009

How to Perform Update Operation With Join in SQL server.

How to Perform Update Operation With Join in SQL server.

How to Perform Update Operation With Join in SQL server.

we can Update any tables data in conjuction with join operation. In case when you have to Update multiple records without where condition and based on some Critearea you can use join with update statement. I have a XML string and want to update all records whose ID contains in this XML string.

Declare @XML xml
set @XML='11112'
Update User_mst set [Name]='Haresh,Herry' from
(
select ParamValues.[Name].value('.','VARCHAR(200)') as [Name]
FROM @XML.nodes('/Project/Id') as ParamValues([Name])
) as N inner join User_mst usr on usr.Id=N.[Name]


Thanks.