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:
  #1  
Old October 5th, 2004, 03:06 PM
Kaya3109 Kaya3109 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: MA
Posts: 4 Kaya3109 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with MS SQL Server - updating data from 2 tables

Hi all,
Please forgive me, but I'm new to MS SQL Server and I have few questions. First of all I'd like to know if there is a way to update one table with the data from another. Let's say I have 2 tables. TableA table contains the voucher numbers; TableB table contains the image numbers. Is there a way to merge Voucher numbers from TableA table to Image numbers in TableB table if we assume that there is a primary key Voucher Number in both tables? If yes- what would be the query structure for that? Please forgive me if you think that this question is silly, I have to say I'm not just new to SQL I'm VERY new to it
Thank you in advance.

Reply With Quote
  #2  
Old October 6th, 2004, 02:38 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,784 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 21 h 42 m 49 sec
Reputation Power: 37
Code:
update t1 set c1 = (select c1 from t2
where t1.pk = t2.pk)
where t1.pk in (select pk from t2)


Is this some reorganization of the datamodel? Otherwise you should not do the update at all as you should never store data in two places.

Reply With Quote
  #3  
Old October 6th, 2004, 08:31 AM
Kaya3109 Kaya3109 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: MA
Posts: 4 Kaya3109 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by swampBoogie
Code:
update t1 set c1 = (select c1 from t2
where t1.pk = t2.pk)
where t1.pk in (select pk from t2)


Is this some reorganization of the datamodel? Otherwise you should not do the update at all as you should never store data in two places.


One of our clients has a file of 183,000+ records representing all voucher numbers that were posted in 2003 and 2004 YTD. That client wants to make sure that we have an image for every one of those vouchers AND also to make sure that any images on file not yet matched properly to “good date” are so matched. I’m sure that this task could be done easily in SQL.
With the voucher number from 183,000+ records on 2003-04 file I need to find image number on file. Sort out any without images matching up and then determine if the invoices are missing.
I thought that I could create a table that would contain the data from 183,000+ records on 2003-04 file and somehow update it with the data from an existing table. Does it make sense? Please correct me if my thinking does not seem logical.

Thank you for your reply.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Help with MS SQL Server - updating data from 2 tables


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT