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
 General SQL Server Forums
 New to SQL Server Programming
 Return ID from another Table

Author  Topic 

cstlaurent
Starting Member

6 Posts

Posted - 2011-06-06 : 17:51:32
Hi,

I need to import on a weekly basis three view from different system in order to populate an application. As usual, the information imported is not normalize. I am looking to insert the element of a table witch is easy. But because I normalize my table I have three field that I want to return the ID of an other table.

Ex. Table import
Mark / Color
Screwdriver / Blue
Screwdriver / Red

Table Colour
Id / Color
1 / Blue
2 / Red

I need to import in my table
Mark / IdColor
Screwdriver / 1
Screwdriver / 2

Thanks in advance for looking into it.

Apparently normalize is better, but here it give me an headhake.



GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-06-06 : 17:57:14
SELECT Mark, Color.ID
FROM Import INNER JOIN Colour on Import.Color = Colour.Color

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -