Hey everyone, I’m stuck with a problem while trying to get my CSV data into SQL Server. The import wizard keeps throwing this error about the Date column:
Data conversion failed: potential loss of data for column "Date". Status value 2.
My dates in the CSV look like this: 1/16/2017 0:00
I’ve played around with the datetime options in the advanced settings, but no luck so far. It’s driving me crazy! Has anyone run into this before? Any tips on how to get these dates to play nice with SQL Server? I’m pretty new to this, so any help would be awesome. Thanks!
I encountered similar issues when importing CSV files with problematic date formats. One effective approach was to use the OPENROWSET function together with a custom format file. In my experience, setting up a format file (using the .fmt extension) allowed me to explicitly map the CSV fields to SQL Server columns, including treating the date column as “datetime”. This method bypasses the limitations of the Import Wizard and offers finer control over data interpretation. For example:
SELECT *
FROM OPENROWSET(
BULK 'C:\\path\\to\\your\\file.csv',
FORMATFILE = 'C:\\path\\to\\format\\file.fmt',
FIRSTROW = 2
) AS data
hey, have u tried the import wizard ‘format’ option? maybe set it as ‘m/d/yyyy H:mm’. also, curious- which sql server version r u usin? older versions might behave a lil diff. what r your thoughts?
yo, i’ve hit that issue before. try converting ur dates to ISO format (YYYY-MM-DD) in the CSV first. u can use Excel or a script to do it. SQL Server likes that format better. if u can’t change the CSV, maybe try specifying the exact format in the import wizard. good luck man!