January 11, 2008 at 10:00 am
Sorry, I think this should go in a beginners section, but there wasn't one. If I run the following SQL statement, all the records in the test database get updated, when all I want is the one that matches in the where clause. How do I do this?
UPDATE s
SET s.src_long_description = c.text
FROM database.dbo.test s, database.dbo.copy_text c
WHERE c.pageName = '/service/extended_description/serviceA'
January 11, 2008 at 10:34 am
I think that you need to JOIN your two tables, as such:
UPDATE s
SET s.src_long_description = c.text
FROM database.dbo.test s
INNER JOIN database.dbo.copy_text c
on S.[PRIMARY KEY] = c.[FOREIGN KEY]
WHERE c.pageName = '/service/extended_description/serviceA'
Where [PRIMARY KEY] is a column in s that uniquely identifies the record, and where [FOREIGN KEY] is a column in c that references the related record in s.
Hope that helps.
-Simon Doubt
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply