I have an excel from where I am bulk importing data to SQL server through .Net code (Dataset.WriteToServer method). Now, my excel has dates in m/d/yyyy format, e.g. 9/21/2021. The destination SQL Server column is varchar and I would prefer not to have to change it in this release. When we run this in one app server, its importing as '9/21/2019' in SQL Server, which I want. However, in another app server, its being imported as '21/9/2021' for the same excel file. This is causing some functionalities to fail in the second server
We checked the System date and time formats in the two servers and in the second server (where the problem occurs), it was d/m/yyyy. We are changing that to m/d/yyyy. Now I have 2 questions,
- Any other changes required at Windows or SQL Server level to do this without code change?
- Do we need to reboot the system/restart IIS or App pool for this change to take effect? Thanks in advance
Thanks to all for your responses. The immediate issue was resolved after changing the system date setting in App servers. However, to avoid managing the nightmare of junk data going into prod (and the other issues all of you correctly highlighted), I did bite the bullet and changed the DB column data type to varchar and let excel and sql talk to themselves with two dates. Issue is of course resolved and I noticed one additional benefit with the second approach which I would like to share.Now the validation whether user is uploading a correct date is being done on the client side itself and the business logic processing in DB is much faster.