ProgrammerAH

Programmer Guide, Tips and Tutorial

Skip to content

Solution of error converting data type varchar to datetime in SQL Server

The Error converting Data type Varchar to Datetime is probably the most common Error of the SQLServer. The Error converting data type Varchar is usually due to the inputting of the date string VarchAR and the default date format in the SQL database, Default_DateFormat, which is commonly found in non-Chinese SQL server. Because SQLServer is available in different languages, the default date format is also “dmy “, “mdy”, “ymd”. Here D is the date, M is the month, and y is the year, but in different order. An error occurs if the date string entered is not in the same order as the default date format of the database system. You can see what language is in what format; you can use the statement from EXEC SP_HELPLANGUAGE.

After checking online, the default language of the database can be set to Chinese to solve the problem, but this only solves the string problem of Insert data, not the problem of using date parameters directly in the StoredProcedure storage method. And for the Chinese date input problem, it is necessary to set the entire database code into Chinese, is not a good solution. And it seems that the date pattern invoked in the StoredProcedure does not depend on the default language of the system, but rather on the version language of the database. Fortunately, SQLServer also provides a method to set the default language of Login Login name, so that we can take the Login account to set the default language of Chinese Login, so as to solve the format conversion error idea.

USE MASTER

EXEC SP_DEFAULTLANGUAGE ‘login name ‘, ‘Simplified Chinese’

This method is tested.

Look at the SQLServer tutorial, it seems that the SQLServer 2005 version of the above, can also be used directly

ALTER LOGIN LOGIN name WITH DEFAULT_LANGUAGE = ‘Simplified Chinese’

But this statement did not compile on my SQL EXPRESS 2008.

In this way, after the user USES the set account to log in, the system default language is the set language, the date format conversion error problem is solved.

This entry was posted in How to Fix and tagged data, login, sqlserver, The database on 2020-11-10 by Robins.

Post navigation

← .. ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[2]: *** Jython installation →

Recent Posts

  • MAFIA: 1- OpenFlow statistics (Counters, Timestamps)(mafia-sdn/p4demos/demos/1-openflow/1.1-statistics/p4src/of.p4)
  • LDSC: Could not open Corces_ATAC_1000Gv3_ldscores/Corces_ATAC.1.1.l2.ldscore[./gz/bz2]
  • Gradle Package Project Lombok Not Working: No serializer found for class com.qbb.User and no properties discovered to create BeanSerializer……
  • [Solved] PCH Warning: header stop not at file scope
  • pymysql Error: File “/usr/local/lib/python2.7/site-packages/PyMySQL-1.0.2-py2.7.egg/pymysql/connections.py”, line 167 SyntaxError: invalid syntax
Proudly powered by WordPress