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
 Transact-SQL (2005)
 nested update

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2007-03-26 : 07:22:19
I have 2 tables. I am trying to normalize table 1. I have 2 fields in table 1 fundID and fundName I pulled all the distinct values out of the fundName column and put them in table 2. Now I have to put the id's from table 2 into the fundID field in table 1. Who do I do this

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-26 : 07:30:58
What is the criteria to assign IDs to the fund names?

Post some sample data and expected output.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2007-03-26 : 07:47:22
I figured it out

UPDATE BIT_HARDWARE
SET FUND_ID =
(SELECT FUND_ID
FROM BIT_FUND
WHERE (FUND_DESC = BIT_HARDWARE.FUND))
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-26 : 08:32:10
You mean this?
UPDATE		h
SET h.FUND_ID = f.FUND_ID
FROM BIT_HARDWARE AS h
INNER JOIN BIT_FUND AS f ON f.FUND_DESC = h.FUND


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -