Saturday 15 March 2014

Importing from Excel to SQL Server: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value -



Importing from Excel to SQL Server: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value -

i have next excel workbook:

https://meocloud.pt/link/7cb3ef48-7556-4d36-ab9a-c247d3f7b29d/fichasteste.xls/

it's formatted imported sql database. server has next details:

as can see mapping right in importer

when seek import excel file, status same, no matter modifications columns date.

242: conversion of varchar info type datetime info type resulted in out-of-range value.

3621: statement has been terminated.

what should modify rows can imported without having error?

excel stores dates integers, if alter excel field text you'll see that, i'm not sure why you're having problem, should able direclty import excel , have dates preserved, @ to the lowest degree can using sql's import wizard ssis.

one workaround using text() function in excel date acceptable format:

=text(f2,"yyyy-mm-dd")

i importing excel using openrowset(), requires additional setup , has it's own drawbacks:

select * openrowset('microsoft.ace.oledb.12.0', 'excel 12.0;database=c:\yourexcelfile.xls', [sheet1$])

sql excel import

No comments:

Post a Comment