sql server - SQL date not converting in OPENROWSET query but does work as admin user -
select cast('01/05/2014' date)
returns: 2014-05-01
but have csv file dates (all in may) written in uk format above. in fact, i'm using top 10 records have date: 01/05/2014
my problem when run below code, results all:
2014-01-05 00:00:00.000 | 2014-01-05 | 2014-01-05 | 2014-01-05 | 2014-01-05 | jan 5 2014 12:00am | 05/01/2014
this code:
select top 10 sdispdate ,convert(date, sdispdate, 103) ,cast(sdispdate date) ,convert(date, cast (sdispdate date), 103) ,cast(convert(date, sdispdate, 103) date) ,cast(sdispdate varchar(50)) ,convert(varchar(20), sdispdate, 103) openrowset('microsoft.ace.oledb.12.0','text;database=d:\import;hdr=yes;format=delimited(,)', 'select * [mydatafile.csv]')
so problem cannot convert uk date uk date. feel issue must have openrowset - ideas?
update: i've run same query on sql 2008r2 server (same mine) , got correct result. both servers show us_english language , mdy dateformat when running dbcc useroptions
update 2: i've run ssms on machine domain admin , works... dbcc useroptions
identical between me , administrator. sysadmin. machine australian no other regional settings. , if connect other server mentioned in first update myself or administrator works. can mean there setting unique login on new server only. else can check??? i've been on issue on 4 hours!!!
gordatron right, ace shafting me before sql got it. meant couldn't make data substring etc.
my solution add schema.ini same folder import file. contents of just:
[mydatafile.csv] datetimeformat=dd-mmm-yyyy
and that's it.
Comments
Post a Comment