Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Query to Compare and then UPDATE

Posted on 2011-02-11
6
Medium Priority
?
264 Views
Last Modified: 2012-05-11
Hi, I am new to SQL, and would like some help please.

I am trying to compare 2 tables only 1 column in those tables. The tables are

1.) dbo.ImportPCMCost
2.) dbo.ImportIncludedList

The 2 tables are:

1.) dbo.ImportPCMCost.Procedure_Code_ID
2.) dbo.ImportIncludedCost.ID

I want to match these 2 Colums and then I want to UPDATE the FEE Column that is located in dbo.ImportIncludedCost table. Please
0
Comment
Question by:dmanisit
[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
6 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 34872374
update dbo.importincludedcost
  set fee =?
 from dbo.importincludedcost as c
 inner join dbo.importpcmcost as p
 on c.id=p.procedure_code_id
0
 
LVL 8

Expert Comment

by:rushShah
ID: 34872431
try this,


update c
set c.fee = CASE WHEN c.ID=p.Procedure_Code_ID THEN '?' ELSE '?' END
from dbo.importincludedcost as c, dbo.importpcmcost as p

Open in new window

0
 
LVL 41

Accepted Solution

by:
Sharath earned 2000 total points
ID: 34872821
UPDATE c 
   SET fee = p.fee -- or any hard coded value 
  FROM dbo.importincludedcost AS c 
       INNER JOIN dbo.importpcmcost AS p 
         ON c.id = p.procedure_code_id

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:dmanisit
ID: 34872865
So I have the Fee in the table ImportPCMCost named Fee that I want to take this Fee and update ImportIncludedList Table Field name Fee also
0
 
LVL 41

Expert Comment

by:Sharath
ID: 34872880
Then try the last statement posted.
0
 

Author Closing Comment

by:dmanisit
ID: 34874512
Thats awesome, thanks.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

604 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