|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Quote:
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. |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Help with MS SQL Server - updating data from 2 tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|