[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SQL Server query to change column value from 0 to 1

Posted on 2012-12-24
4
Medium Priority
?
374 Views
Last Modified: 2012-12-25
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
Comment
Question by:dave_sky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Assisted Solution

by:Jared_S
Jared_S earned 1000 total points
ID: 38719301
The syntax to set the value of the column to the value + 1 for every row is

update table1

set columnname = columnname + 1
0
 

Author Comment

by:dave_sky
ID: 38719509
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
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 38719961
update table1
set columnname = columnname + 1
where columnname = 0
0
 

Author Closing Comment

by:dave_sky
ID: 38720112
Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will useā€¦
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question