I wonder if Kalen Delaney's internals book cover's bcp.ĮXEC master.xp_cmdshell 'bcp 99 in d:\data\Northwind_dbo_myTable99.dat -Usa -P -S -c -q' I don't understand the internals of the bulk copy program (bcp) but I'm sure it's reading the sql server catalog and is not handling the reserve words correctly. You'll notice there is very little difference in the bcp's. The Error is that a reserve word causes bcp to fail In case anyone else runs into this, here is the real problem with the original code: retCode SQLSetConnectAttr(ConnectionHandle, SQLATTRLOGINTIMEOUT, &timeout, 0) The SQLATTRLOGINTIMEOUT attribute takes an integer by value, not a pointer to an integer.
Navigate to the Administrative Tools via StartControl Panel. Re: Error = Incorrect syntax near the keyword 'DESC'.Įrror occured when you try to execute bcp, maybe this 'bcb' contains some errors ? SQL statment is valid The initial step in creating any Data Source Name (DSN) is locating the Data Sources (ODBC) Control Panel icon. SET NOCOUNT OFF DROP VIEW myView99 DROP TABLE myTable99 GO INSERT INTO myTable99 (Col1, ) SELECT 1, 'I' UNION ALL SELECT 2, 'Me' UNION ALL SELECT 3, 'Mine' GOĮXEC master.xp_cmdshell 'bcp 99 out d:\data\Northwind_dbo_myTable99.dat -Usa -P -S -c' GOĮXEC master.xp_cmdshell 'bcp 99 in d:\data\Northwind_dbo_myTable99.dat -Usa -P -S -c -q' GOĬREATE VIEW myView99 AS SELECT Col1, AS Col2 FROM myTable99 GOĮXEC master.xp_cmdshell 'bcp 99 in d:\data\Northwind_dbo_myTable99.dat -Usa -P -S -c' GO SET NOCOUNT ON CREATE TABLE myTable99(Col1 int, varchar(8000)) GO If anyone has a slicker way, or better, an explanation as to why bcp does fail, I'm all ears.or is that eyes? In any case.something for future reference so I don't have to remember it, and hopefully someone else might benefit. The work around I used was to create a view. I have never run into this before (mostly because I don't use reserve words as column names). Enclose the entire three-part table or view name in double quotation marks (" "). Use this option to specify a database, owner, table, or view name that contains a space or a quotation mark. It's curious why there isn't a problem with the bcp out though.Įxecutes the SET QUOTED_IDENTIFIERS ON statement in the connection between the bcp utility and an instance of SQL Server. So that solves that problem, and I'm sure it's one that I won't forget. As BOL states, it sets quoted identifiers on in the context of the bcp thread. The resolution to this problem is the -q option. Starting in SQL Server 2005, the SQL 'Server Native Client 10.x/11.x/12.x' includes an ODBC interface and is the ODBC driver that shipped with SQL Server 2005 through SQL Server 2012.
It is not recommended to use this driver for new development.
ODBC DRIVER FOR SQL SERVER 2005 WINDOWS
Thanks Tara (again) for pointing out the obvious. The first 'SQL Server' ODBC driver still ships as part of Windows Data Access Components. Error = Incorrect syntax near the keyword 'DESC'.īcp fails to import data near reserved word.Īlrighty then.