MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 12th, 2004, 01:11 PM
dwan dwan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 4 dwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
simple query help?

Hi,

I hope this is an ok place to ask a very basic question, as I find myself in a position to need to write queries suddenly with no training or experience writing queries.

What I am trying to accomplish is this: A new pricing spreadsheet came from the manufacturer, I imported that info into an sql table in the database. Now I want to write a query that will look at my new table, compare it to an existing table and update any new or changed information in the existing table.
Below is what I have come up with so far, but I'm not even sure if I am on the right track. Any help at all would be appreciated.

Update IV00101
From Big_Boy2
Where IV00101.ITEMNMBR = Big_Boy2.SKU
where IV00101.GEDESC = BIG_BOY2.MANUFACTURER
where IV00101.currcost = big_boy2.netprice
where IV00101.stndcost = big_boy2.sellprice
where IV00101.itemdesc = big_boy2.descript


Thanks,

dwan

Reply With Quote
  #2  
Old January 12th, 2004, 04:27 PM
dwan dwan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 4 dwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am learning slowly but surely. If they want me to do this I am going to need a good tutorial. Can anyone suggest a good one at a decent price?

With reguard to the above question, am i on the right track thinking I need to use an inner join statement?

Thanks in advanca for any help!

Dwan

Reply With Quote
  #3  
Old January 12th, 2004, 05:08 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
--Insert
Insert into currTable
SELECT *
FROM oldTable
where oldTable.primaryKey NOT IN(SELECT currTable.primaryKey
FROM currTable)

--Update
update currTable
set currTable.col1 = newTable.col1
where currTable.primaryKey = newTable.primaryKey

--How are you handling deletes?
__________________
El éxito consiste en una serie de pequeñas victorias día a día

MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html

Last edited by victorpendleton : January 13th, 2004 at 09:06 AM.

Reply With Quote
  #4  
Old January 13th, 2004, 09:03 AM
dwan dwan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 4 dwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
There should not be too many to delete. I am going to run a compare script and then just manually delte the few that turn up. Thank you so much for your help!
dwan

Reply With Quote
  #5  
Old January 13th, 2004, 09:05 AM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Did this SQL work for you?

Reply With Quote
  #6  
Old January 13th, 2004, 09:23 AM
dwan dwan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 4 dwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it almost worked! Insert did, Update did not. However I think I got it using this:

update IV00101
set IV00101.col1 = BIG_BOY2.col1

From IV00101, BIG_BOY2
where IV00101.primaryKey = BIG_BOY2.primaryKey



but am just now getting ready to test. I will let you know how it goes.

Thanks,

dwan

Reply With Quote
  #7  
Old January 13th, 2004, 10:12 AM
jstrohofer jstrohofer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Cincinnati, OH USA
Posts: 111 jstrohofer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 3 sec
Reputation Power: 5
You won't really want to use the FROM statement in your update.

You'll probably want something more along these lines:

update IV00101
set IV00101.col1 = BIG_BOY2.col1
where IV00101.primaryKey = BIG_BOY2.primaryKey

Good luck!

-- Jill

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > simple query help?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway