Friday, 6 September 2013

Update multiple rows using single value

Update multiple rows using single value

I have a single value of 9/1/2013 for a mailing date. I also have 50 row
primary key IDS that need to be updated with this single mail date of
9/1/2013.
UPDATE myTable
SET MailingDate = CONVERT(DATETIME, '2013-09-01 00:00:00', 102)
WHERE (tblID = 1) OR
(tblID = 2) OR
(tblID = 3) OR
(tblID = 4) OR ETC...
I have seen some questions about table to table, so i suppose the next
question would be. Am i going to be forced to create a tempTable with an
ID column and MailDate column and Inner Join it with the actual table I
want to update?
Is there way to do this update that doesnt require me have to make my
WHERE statement so huge or the whole creating a tempTable way? Any help
would be greatly appreciated.

No comments:

Post a Comment