Solved

Link tables with primary key

Posted on 2013-06-08
2
509 Views
Last Modified: 2016-02-11
Hello there,

I have two table which I imported from excel using SSIS. now I am trying to create the link between these tables. I need to transfer the pk of the table1 to table2. please see shot. one way is to
do this for every code but I have around 100,000 records. is there some easy and faster way to this. I am using mssql 2008

UPDATE
    city
SET
    pid = 8
WHERE 
        OstanCode = 10;

Open in new window

db.gif
0
Comment
Question by:zolf
2 Comments
 
LVL 11

Accepted Solution

by:
Deepak Lakkad earned 500 total points
ID: 39232568
Hi,

I assumed that there are two tables named as Table_1 and Table_2.

You want to update PID column of Table_2 with ID column of Table_1.

If I am right, you can try following query to update your second table.


UPDATE	Table_2
SET		pid = Table_1.id
FROM	Table_1
		INNER JOIN Table_2 ON Table_1.code = Table_2.code

Open in new window


- Deepak Lakkad
0
 

Author Closing Comment

by:zolf
ID: 39232790
thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
A couple of weeks ago, my client requested me to implement a SSIS package that allows them to download their files from a FTP server and archives them. Microsoft SSIS is the powerful tool which allows us to proceed multiple files at same time even w…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

813 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

11 Experts available now in Live!

Get 1:1 Help Now