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
 copy field to another table

Author  Topic 

EricBHK
Starting Member

18 Posts

Posted - 2012-10-11 : 18:08:35
Hi !

I have two completely identical tables, the first with the name
ParcelTaxes2008OldTemp
and the second with the name
ParcelTaxes2008Old

I want to copy one specific field (Tax2008ProvinceNominal) from the first table into the second table, using an identical field called 'ParcelNumber' as row indicator.

I have the following statement, but it gives an error and I am unable to find out why (tried several alternatives already) :


sql = "UPDATE ParcelTaxes2008Old SET Tax2008ProvinceNominal = (SELECT Tax2008ProvinceNominal" _
& " FROM ParcelTaxes2008OldTemp WHERE ParcelNumber = " & TextBox1.Text & ") WHERE ParcelNumber = " & TextBox1.Text



Any suggestions ?


Thanks !

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-11 : 18:55:23
sql = "UPDATE o SET o.Tax2008ProvinceNominal = ot.Tax2008ProvinceNominal FROM ParcelTaxes2008OldTemp ot INNER JOIN ParcelTaxes2008Old o ON ot.ParcelNumber = o.ParcelNumber WHERE ot.ParcelNumber = " & TextBox1.Text



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

EricBHK
Starting Member

18 Posts

Posted - 2012-10-12 : 01:18:19
Hi Visakh16,

I tried your solution, but I am getting a Syntax error message (missing operator).

Should there not be an additional WHERE conditions just before the INNER JOIN part ?



Thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-12 : 12:57:51
Post the error
no need of WHERE before INNER JOIN


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

EricBHK
Starting Member

18 Posts

Posted - 2012-10-12 : 13:04:42
As per your equest, here is the 'OleDB exception was unhandled' error :

Syntaxisfout (operator ontbreekt) in query-expressie ot.Tax2008ProvinceNominal FROM ParcelTaxes2008OldTemp ot INNER JOIN ParcelTaxes2008Old o ON ot.ParcelNumber = o.ParcelNumber.

syntaxisfout = syntax error (eng)
operator ontbreekt = operator missing (eng)


Regards
Go to Top of Page
   

- Advertisement -