Search code examples
sqlsql-serverazure-sql-databasessmscsv-import

date converting incorrectly with ssms import data wizard (Azure db)


I have update and delete permissions (not ALTER) for a Azure db table and am trying to import a CSV file using the SSMS import data wizard. The import works ok except that it changes the date in a field to today's date. For example the field on the CSV looks like this:
"Jun 01, 2018 01:37AM"
After it runs through the wizard it looks like this in my table:
2018-06-13 01:37:00.000
The datatype that I chose for the date in my CSV file during the import was:
database time [DT_DBTIME]
The datatype specified for that field in my table is:
datetime

Any idea what I'm doing wrong? Am I choosing the wrong datatype for the field in the csv?


Solution

  • It is because of the file data type (DT_DBTIME). This is not the correct datatype, you need to choose DT_DBTIMESTAMP to map correctly to datetime. I presume it is using the current date of the SQL server and is in effect only importing the time (01:37AM) element from your csv.