February 26, 2008 at 6:36 am
I have been asked to replace values from a field in a 'Products' table.
I have been asked to replace all values in a field with a 0 (if not zero already)
Does the following command look correct:
UPDATE [Database].[schema].[Table]
SET column_name = 0
WHERE column_name >0
Many Thanks,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
February 26, 2008 at 6:42 am
Phil
If it's zero already then it won't matter if you update it to zero, so this will work just as well:
UPDATE [Database].[schema].[Table]
SET column_name = 0
John
February 26, 2008 at 6:46 am
Thanks. Now that's what I call a speedie response.
My version ran and said it affected 33000 rows, however there were still records with a value of 1 or above.
I ran your version and all records now read 0 for that column name.
Many Thanks,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply