I am using bcp utility to import a tab delimited file. My table has an identity column, when I run bcp command I get error as
Error = [Microsoft][SQL Server Native Client 11.0] Invalid date format
Second column is datetime. When i use -E
flag (as suggested by many), I get error as
Error = [Microsoft][SQL Server Native Client 11.0] Invalid character value for cast specification
Everything works when I don't have the identity column. I am not sure what is missing here.
Here is a repro:
CREATE TABLE [dbo].[test_temptable]
(
[ID] int NOT NULL IDENTITY PRIMARY KEY,
[Date] [datetime] NULL,
[Column2] [varchar](100) NULL,
[Column3] [varchar](100) NULL,
)
ON [PRIMARY]
GO
Test Data (testTempTable.txt - TAB DELIMITED):
15-Sep-18 TestColumn2 TestColumn3
BCP Command.
bcp "testDB.dbo.test_temptable" in "c:\temp\test\testTempTable.txt" -c -t"\t" -T -S "testSQlServer" -E -e c:\temp\test\error.csv
When I drop the [ID]
column from table and run , everything works fine.
What am I doing wrong?
EDIT: Value assigned when table does not have Identity Column
useful links: