Avatar of batchakamal
batchakamalFlag for India

asked on 

Easiest way to insert lookup data along with master data

I have a master table in which more than 25 foreign keys are there pointing to different lookup tables.

For eg, I have a table called StudentMaster with

StudentID (PK),
StudentName,
CountryId (FK),
MartialStatus (FK),
Degree (FK),
MajorSubject (FK),
MinorSubject (FK),
University (FK) etc..

Now I am importing data from a temporary table and they have provided the values instead of codes in the Foreign Key values. Now I need to write a script to import these data into my table. When importing data if any lookup value found I need to insert them into the lookup table and then insert the master data along with new lookup codes.

Please advice..
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
batchakamal
Avatar of kaminda
kaminda
Flag of Sri Lanka image

First migrate all the lookup tables first using a script. Then migrate data to the table (master table as you have mentioned) by joining the lookup tables. Also you can use series of update scripts to update master table after migrating only the non fk columns for the master table.
Avatar of batchakamal
batchakamal
Flag of India image

ASKER

Yes, I know this basic.

How can I do this just in one step... can we use MERGE??
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of batchakamal
batchakamal
Flag of India image

ASKER

I am expecting something more easier than this.
Microsoft SQL Server 2008
Microsoft SQL Server 2008

Microsoft SQL Server 2008 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. Major improvements include the Always On technologies and support for unstructured data types.

50K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo