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 Administration
 SQL Query

Author  Topic 

Jaykappy
Starting Member

19 Posts

Posted - 2011-12-09 : 17:01:38
I have Table 2 and Table 1
Many to One relationship

I need to update the Multiple rows in Table 2 field "ParentGUID"
where Table 1 field "NumofEmpe" and Table 2 Field "CB_ID" are equal...

Noting that Table 1 has unique values and Table 2 has multiple...I need teh multiple/duplicate values to populate in Table 2.
This will give me the unique values I need to create the relationship

Trying something like this...getting syntax errors

UPDATE Table2 INNER JOIN Table2 ON Table1.NumofEmpe = Table2.CB_ID
SET Table2.ParentGuid = [Table1].[ParentGUID]
WHERE (((Table2.CB_ID)=[Table1].[NumofEmpe]));

Incorrect syntax near Keyword 'INNER'

Thoughts?
Thanks

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2011-12-09 : 17:06:43
You're close.

UPDATE t2
SET t2.ParentGuid = t1.[ParentGUID]
FROM Table2 t2
INNER JOIN Table1 t1 ON t1.NumofEmpe = t2.CB_ID
Go to Top of Page

Jaykappy
Starting Member

19 Posts

Posted - 2011-12-12 : 09:30:13
Awesome Thanks
Go to Top of Page
   

- Advertisement -