SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 copy field to another table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

EricBHK
Starting Member

18 Posts

Posted - 10/11/2012 :  18:08:35  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 10/11/2012 :  18:55:23  Show Profile  Reply with Quote
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 - 10/12/2012 :  01:18:19  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 10/12/2012 :  12:57:51  Show Profile  Reply with Quote
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 - 10/12/2012 :  13:04:42  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000