January 14, 2010 at 3:07 pm
I am trying to write a script that will automatically update. I'm thinking I need a nested update statement with the possibility of using a temp table or table variable.
Here is my manual process:
--first I grab all the ID's that have a status of 4
Select MessageID
From MessageQueue
Where MessageStatusID = 4
--Then I put the messageID's from the results of the above query into the where clause
UPDATE MessageQueue
SET MessageID = 1
WHERE MessageID in (<results from above query>)
Thanks in advanced!
January 14, 2010 at 3:27 pm
greggoble2 (1/14/2010)
--first I grab all the ID's that have a status of 4Select MessageID
From MessageQueue
Where MessageStatusID = 4
--Then I put the messageID's from the results of the above query into the where clause
UPDATE MessageQueue
SET MessageID = 1
WHERE MessageID in (<results from above query>)
This seems overcomplicated to me. Wouldn't it be easier to do this . . . ?
update MessageQueue
set MessageID = 1
where MessageStatusID = 4
+--------------------------------------------------------------------------------------+
Check out my blog at https://pianorayk.wordpress.com/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply