Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Link tables with primary key

Posted on 2013-06-08
2
Medium Priority
?
545 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
[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
2 Comments
 
LVL 11

Accepted Solution

by:
Deepak Lakkad earned 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
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…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

722 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