Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date format in SQL

Author  Topic 

SarahLOR
Starting Member

18 Posts

Posted - 2010-04-09 : 04:44:07
I am doing a bulk insert into table from a csv file.
The csv file has dates in it formatted to DD/MM/YYYY, but this is causing an error during insert as I believe SQL server is set to MM/DD/YYYY.

Can anyone tell me how to change the date format on the server. I have changed the language to 'British english' but am still getting the error.

Thanks,
Sarah

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-09 : 04:45:59
The command (per session) is

SET DATEFORMAT dmy (for day month year)


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2010-04-09 : 04:49:38
Hi

Refer this

http://www.sql-server-helper.com/tips/date-formats.aspx

-------------------------
/R..

Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-09 : 04:55:54
quote:
Originally posted by rajdaksha

Hi

Refer this

http://www.sql-server-helper.com/tips/date-formats.aspx

-------------------------
/R..




That's not going to help as he's trying to import character data as dates. Not express dates as character data.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

SarahLOR
Starting Member

18 Posts

Posted - 2010-04-09 : 05:10:26
Thanks, is there a way to do it on the server side?
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-09 : 05:18:59
how are you doing the bulk insert?

The DATEFORMAT setting only determines how a character string is parsed into a datetime column / variable.

The best thing you could do would be to reformat the data you are trying to import into the short ISO form which is yyyymmdd.

Are you issuing a BULK IMPORT command from a management studio window? How are you trying to import the data?




Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -