Subhash Kr Singh (1/28/2011)
Hi Rahul,I am just new to sql server. But I just want to know one simple question what will be the statement if i want to update a particular column of all rows i.e.
UPDATE tablename SET name = 'test'
Will it work?
Thanks,
Hi Subhash
Best way to answer questions like this is to have a go! SQL Server Express is free, and the syntax is the same as all the paid-for versions. Set up a test environment and try some things out.
The straight answer to your question is yes, what you have written will update *all* the rows. That leads to the point of this article - if in standard SQL you issue an update or delete command without specifying which rows you want it to apply to (i.e. without a WHERE clause), it will indeed update all the rows. It is an easy mistake to make - to forget the WHERE clause and then end up trashing all the rows - which is why the author of the article we're discussing came up with a (flawed) trigger to try to prevent that.
Jinlye
PS Don't be put off asking because of earlier responses.