Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi.Same DB I have a joined query which gives me back the relevant data that I need to update, with the values to update with from the join table (in this case the column rightTableType)how would I do this?select pi.tabletype AS 'leftTableType', publicationid, p.id, p.TableType AS 'rightTableType'from publicationItem piinner join Publication p on pi.PublicationId = p.Id
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2011-09-09 : 12:18:17
Not clear to me which the source column is and which the destination column is, but assuming it is the table types, you can do something like this:
with cte as (select pi.tabletype AS 'leftTableType', publicationid, p.id, p.TableType AS 'rightTableType'from publicationItem piinner join Publication p on pi.PublicationId = p.Id) update cte set leftTableType = rightTableType