Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Saturday, 13 April 2013

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

Have encountered with an sql error after running following sql:
INSERT INTO [Member](FirstName, LastName, CreationDate, LastActivityDate) 
VALUES ('Saif', 'Ikram' , '13/04/2013 22:15:44', '01/01/1753 00:00:00')
go

"The conversion of a varchar data type to a datetime data type resulted in an out-of-range value". Actually there is nothing wrong with sql. Now run following sql to see if this works
set language british
go
INSERT INTO [Member](FirstName, LastName, CreationDate, LastActivityDate) 
VALUES ('Saif', 'Ikram' , '13/04/2013 22:15:44', '01/01/1753 00:00:00')
go

Now surprisingly this works, only addition is assigning language to "British". As I am using NHibernate this still is not acceptable. So I have updated my default language
USE CSharpTechies;
GO
EXEC sp_configure 'default language', 1033 ; 
GO
RECONFIGURE ;
GO
1033 for "British English" as described in msdn sys.syslanguages. But this also failed. The reason was the user that sql is run as. So update the language setting for user
EXEC sp_defaultlanguage 'saif', 'british'
sql now executes without any error

Education makes machines which act like men and produces men who act like machines. ~Erich Fromm

0 comments:

Post a Comment

Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers