Solved

Combining two update queries

Posted on 2008-10-16
7
143 Views
Last Modified: 2010-04-21
Hi,
Can anybody help me....I have data in a column which contain:
Fulltime
Fultime
Fulltime
Partime
Partime

Now I want to change all fulltime words with Waiting and partime words with Placed.

Do you know how to do this?
0
Comment
Question by:Dhehien
  • 4
  • 2
7 Comments
 
LVL 14

Expert Comment

by:Binuth
ID: 22729924
try this
update tableName
	set ColName = case when ColName= 'Fulltime' then 'Waiting' 
				 else
					case when ColName= 'Partime' then 'Placed' end
				end

Open in new window

0
 
LVL 6

Expert Comment

by:divyeshhdoshi
ID: 22729957
update <tablename>
set <columnname> =
                      case <columnname>
                               when 'Fulltime' then 'Waiting' when 'Partime' then 'Placed'
                      End
0
 

Author Comment

by:Dhehien
ID: 22730004
It doesn't work, it says "cannot update (column_name) to null"
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 14

Accepted Solution

by:
Binuth earned 500 total points
ID: 22730026
hmm.. your column not allow null values...
try now

update tableName
        set ColName = case when ColName= 'Fulltime' then 'Waiting' 
                                 else
                                        case when ColName= 'Partime' then 'Placed' else ColName  end
                                end

Open in new window

0
 

Author Comment

by:Dhehien
ID: 22730057
Thanks heaps, It works!!!!
0
 

Author Closing Comment

by:Dhehien
ID: 31506680
Awesome
0
 

Author Comment

by:Dhehien
ID: 22730540
Hi...the data in the column that just  changed was created from other table, apparently it also change the original data. Is there anyway to avoid this?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

809 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