Odd SQL Error Reported by Server..

JaedenRuiner

Well-known member
Joined
Aug 13, 2007
Messages
340
Programming Experience
10+
Yes I am using ad-hoc queries, which means that yes, sometimes the DB side of SQL Server is Confused with regards to the Excel Side of the File on what "format" a column is. even if the excel is set to be Text, but it is a number the DB sometimes gets confused.

here is one SQL Statement that executes with no errors, no problems, and works just great:
VB.NET:
SELECT 	
	[A].[Pool Account# ], [A].[Contact Name 1], [A].[Contact Name 2 ], 
	[A].[E-Mail Address 1], [A].[E-Mail Address 2], [A].[Alternate Contact], 
	[A].[Comments]
FROM 	OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\db\Imports\Master.xls', [AllPoolCorbi103008$]) AS [A]
WHERE 	([A].[Pool Account# ] IN ('100117', '100155', '100245', '100328'));

however these two SQL statements return the following error:
VB.NET:
UPDATE OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\db\Imports\Master.xls', [AllPoolCorbi103008$])
SET 	[Contact Name 2 ]='Name', 
	[E-Mail Address 2]='Name@Domain', 
	[Alternate Contact]=''
WHERE 	([Pool Account# ] IN ('100154'));
-----------------   
UPDATE OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\db\Imports\Master.xls', [AllPoolCorbi103008$])
SET 	[Contact Name 2 ]='Name', 
	[E-Mail Address 2]='Name@Domain', 
	[Alternate Contact]=''
WHERE 	([Pool Account# ] = '100154');

"UPDATE AllPoolCorbi103008$ set `Contact Name 2 ` = 'Rita Garner',`E-Mail Address 2` = 'Rita.Garner@dpsg.com',`Alternate Contact` = 'Gary Nelson <Gary.Nelson@dpsg.com>' WHERE `Pool Account# `=(1.001540000000000e+005)"
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Syntax error in UPDATE statement.".

Any ideas why it is trying to convert the '100154' into a floating point numeric when i have it in Single Quotes?

Thanks
 
Back
Top