UK Dates in Tab delimited file not importing correctly.
I've posted this on SSC as well but so far not had a suitable response. Hoping that I get an answer here.
I have a range of some 40 tab delimited txt files to load into a SQL Server 2008R2 database. These range in size from 2k to 14GB. Dates in these files are in the DDMMYY, DDMMYYYY, DD/MM/YY, DD/MM/YYYY (or YYYYMMDD being imported as varchar) format. Some columns can have a mixture of 2 and 4 digit years.
The box on which SQL Server has been installed was for some unknown reason set to US (I'm in the UK, the box is in the UK, the data is all UK data and we are a UK organisation). Apparently this is now UK localisation. I cannot change this on this pre production environment anyway. I believe that the live environment is correct. SQL Server, all of the users etc, I have changed to the correct UK settings. Originally when they set the instance up they defaulted it all to US and I had to change it to British English
All the receiving tables have been created with the correct data types set. Dates have been set to datetime.
When using SSIS to import the data (I can only use SSIS for operational reasons), the dates are incorrectly imported. Originally I thought converting to a US date format but further investigation shows many inconsistencies.
If I bring the date data in as say varchar and then validate using the isdate function SQL Server returns 1 as a valid UK date. If I alter the table and add a date (not datetime) column and update the new column the dates are converted correctly. If it's a datetime column the data is incorrect although not as inconsistent as via SSIS.
I have also tested this process on two other environments (both of which I configured personally from scratch some time ago) and I can not replicate this issue with the test data I have.
Interestingly, when using the SSIS wizard on my machines the Locale defaults to English (United Kingdom). On the their machine it defualts to English (United States) and I have to change the locale manually to be UK
As an adendum to this, We have also checked the default user in the registry and this is set correctly too.
So (finally) my questions are as follows:-
Why can't SSIS correctly convert the dates to the UK date format? Why does it think it needs to convert it to US or derrivative thereof?
How can I get SSIS to import the data correctly or am I going to have to use the subsequent update method described above.
I can provide a sample data file, sample table structure and screen prints if requested.
Many thanks in advance.
John
|