Solved

Combining two update queries

Posted on 2008-10-16
7
139 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now