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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Import data from Excel column to Sql database colu

Author  Topic 

hspatil31
Posting Yak Master

182 Posts

Posted - 2009-01-20 : 05:40:48
Dear All,

I tried following queary but it gives error. I don't understad what's error is that. What is missing in that. Can anybody plz tell me ? I am trying one column data of Excel copy to one column of SQL database.

Queary:

Update CRD7 T1 Set T1.TaxId0 = T2.TaxId0 from
(Select * FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Book1.xls;HDR=YES',
'SELECT * FROM [Sheet1]'))T2 Where
T1.CardCode = T2.CardCode

Error:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'T1'.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'T2'.

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-01-20 : 07:34:08
[code]Update T1 Set T1.TaxId0 = T2.TaxId0 from
(Select * FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Book1.xls;HDR=YES',
'SELECT * FROM [Sheet1]'))T2,CRD7 T1 Where
T1.CardCode = T2.CardCode[/code]
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-01-21 : 02:41:27
Use ANSI Join

Update T1
Set T1.TaxId0 = T2.TaxId0
from
(Select * FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Book1.xls;HDR=YES',
'SELECT * FROM [Sheet1]'))T2
INNER JOIN CRD7 T1
ON T1.CardCode = T2.CardCode



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -