![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, We've migrated from SQL 7 to SQL 2000 and it seems that some of the existing UPDATE statements aren't working correctly. -- current -- (SQL 7) update company_items_quarterly set company_id = c.company_id from company_items_quarterly cq, company c where cq.ticker = c.ticker --------------- -- Modified -- (SQL 2000) update cq set cq.company_id = c.company_id from company_items_quarterly cq, company c where cq.ticker = c.ticker --------------- will any of these statements work on SQL 7 and SQL 2000? It seems to me that some procedures that use the UPDATE w/ JOIN work, and some don't. tnx in advance! |
#3
| |||
| |||
|
|
It is always a good idea to alias the tables and prefix the columns with the appropriate alias so as there is no mistaking what they are supposed to be. YOur using an alias for the FROM but not in the UPDATE part. You might also get in the habit of using the ansi syntax for joins by using the ON clause instead of the WHERE condition and stating the JOIN syntax as well. But for Updates ina JOIN try this: update cq set company_id = c.company_id from company_items_quarterly cq INNER JOIN company c ON cq.ticker = c.ticker You state that it wasn't working correctly, were you getting an error? -- Andrew J. Kelly SQL Server MVP "Joca" <jjone99 (AT) hotmail (DOT) com> wrote in message news:cfe6019d.0307131123.58d6f434 (AT) posting (DOT) google.com... Hello, We've migrated from SQL 7 to SQL 2000 and it seems that some of the existing UPDATE statements aren't working correctly. -- current -- (SQL 7) update company_items_quarterly set company_id = c.company_id from company_items_quarterly cq, company c where cq.ticker = c.ticker --------------- -- Modified -- (SQL 2000) update cq set cq.company_id = c.company_id from company_items_quarterly cq, company c where cq.ticker = c.ticker --------------- will any of these statements work on SQL 7 and SQL 2000? It seems to me that some procedures that use the UPDATE w/ JOIN work, and some don't. tnx in advance! |
![]() |
| Thread Tools | |
| Display Modes | |
| |