Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 data import to a multiple tables

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2011-06-13 : 04:37:25
Dear All,

I need to import a values from a temp table to multiple tables.

Here i need to do a look up to reference table,kindly suggest me the how we can do this.

ID| category| name| speciality
1 ABC Ram physics
2 XYZ Bhim Chemistry
3 ZLN Zac Maths


lis_Category table

ABC 10
XYZ 20
ZLN 30

list_speciality

physics 1A1
Chemistry 2B2
Maths 3C3


Final output should be in the form of
ID category name speciality
1 10 Ram 1A1
2 20 Bhim 2B2
3 30 Zac 3C3

Pls help me


Thanks,
Gangadhara MS
SQL Developer and DBA

ayadav0984
Starting Member

21 Posts

Posted - 2011-06-13 : 06:27:54
try this out:

assuming the lis_category table field names as : name, id2

select a.id,b.id2,a.name,a.speciality into new_table from table1 a,lis_category b where a.name=b.name

update new_table set speciality=c.speciality from new_table a,list_speciality c
and a.speciality=c.speciality
Go to Top of Page
   

- Advertisement -