SQL Server query to change column value from 0 to 1

dave_sky
dave_sky used Ask the Experts™
on
Software: SQL Server 2005

I am looking for a query to change a specific column value from 0 to 1.

Example:
I have a table column that is always numbered 0, 1, 2, 3, etc. I want to change it so it numbers 1, 2, 3, 4 etc

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2012
Commented:
The syntax to set the value of the column to the value + 1 for every row is

update table1

set columnname = columnname + 1

Author

Commented:
Is there a syntax that will change the row value to 1........only if the value is 0?

I have existing table entries with the value of 1 which I don't want the value changed.
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
update table1
set columnname = columnname + 1
where columnname = 0

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial