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
 udate with join

Author  Topic 

a.ashabi
Posting Yak Master

117 Posts

Posted - 2008-03-07 : 17:56:27
Hi.I have 2 tables with this join

dbo.tbl_product_prop INNER JOIN
dbo.tbl_product ON dbo.tbl_product_prop.product_id = dbo.tbl_product.product_id

all the product_id on tbl_product_prop has to be change.

how can I update the product_id of tbl_product-prop with the Product_id of the tbl_product,so when it replace the related information dont change.thanks
bye

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-03-07 : 18:05:46
Update tbl_product_prop
Set Product_ID = tbl_product.Product_ID
FROM tbl_product INNER JOIN tbl_product_prop
tbl_product ON tbl_product_prop.product_id = tbl_product.product_id



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

a.ashabi
Posting Yak Master

117 Posts

Posted - 2008-03-07 : 18:09:11
thanks for yr help but I've got this errer with it.
The correlation name 'tbl_product'has the same name as t'tbl_product'
thank u again
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-03-07 : 18:15:24
Sorry.. had a type which ended up aliasing the one table so they both had the same effective name.

This is non-typoed.

Update tbl_product_prop
Set Product_ID = tbl_product.Product_ID
FROM tbl_product INNER JOIN tbl_product_prop
ON tbl_product.product_id = tbl_product_prop.product_id



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

a.ashabi
Posting Yak Master

117 Posts

Posted - 2008-03-07 : 18:23:24
thanks.it didnt give me the error but,it change only 1 row.but I have 350 rows!!!
sorry I'm new and I really need help.
thanks
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-03-07 : 18:32:30
quote:
Originally posted by a.ashabi

thanks.it didnt give me the error but,it change only 1 row.but I have 350 rows!!!
sorry I'm new and I really need help.
thanks



It was a full table update. If it only change one row, then your join is attempting to connect on columns that do not entirely match.

If they do not match on "something" you cannot do the update in this fashion.

Perhaps some sample data to illustrate your problem?





Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

a.ashabi
Posting Yak Master

117 Posts

Posted - 2008-03-07 : 18:35:46
thanks a lot I have to work on it.
Go to Top of Page
   

- Advertisement -