I’ve been using the following BCP command for a long time, but the producers of my data changed the date time format of the data and now it fails with invalid cast specifications.
Does anyone know how I can BCP in the data shown below given that the column taking the two date values is of SQL Server DateTime datatype?
bcp IDSCHEME in C:\IDSCHEME_20120926_1517.bcp -F2 -w -t"|^|" -r"|!|\n" -Uuser
-Ppass -Slocalhost
Here’s a sample of the header row and the first data row in the new file:
SchemeID|^|ActiveFrom|^|ActiveTo|^|UniqueName|^|SchemeEnglishName|!|
15000|^|1900-01-01T00:00:00|^|9999-12-31T00:00:00|^|BC|^|Business Classifications|!|
... lots more rows.
Answer: SQL Server BCP does not currently support this date-time format. You can use SQLCMD command line utility and BULK INSERT to mimic the functionality if required that way you don’t have to transform your data files.