• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

SQL Server query to change column value from 0 to 1

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!
0
dave_sky
Asked:
dave_sky
  • 2
2 Solutions
 
Jared_SCommented:
The syntax to set the value of the column to the value + 1 for every row is

update table1

set columnname = columnname + 1
0
 
dave_skyAuthor 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.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
update table1
set columnname = columnname + 1
where columnname = 0
0
 
dave_skyAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now