Get the App
SLTechnology News&Howtos  ›  Database  › 

How to display error messages in different languages by sql server

Shulou Source: shulou.com Published: 2022-06-01 09:07:00 09月24日 Update

This article mainly explains how sql server uses different languages to display error messages, the content is clear, interested friends can learn, I believe it will be helpful after reading.

Question:

The operating system and database of the production environment may be in English, but our mother tongue is Chinese. if we have a poor command of English, we may sometimes fail to understand the wrong English prompt of the database in the English environment. if you directly use English error prompts to be translated through translation tools, it is not necessarily 100% accurate.

Solution:

Specify a language through set language, so that the error report of sql server is presented in that language.

Script:

/ * description: specify a language through set language Make sql server's error report present the script in that language Source: https://www.cnblogs.com/zhang502219048/p/12826544.html reference: https://docs.microsoft.com/zh-cn/sql/t-sql/statements/set-language-transact-sql?view=sql-server-2017 reference Table: select * from sys.syslanguages*/--Divide by zero error encountered.set language US_ENGLISHbegin try declare @ I int = 1 / 0end trybegin catch select ERROR_MESSAGE () As ErrorInfoend catchgo-- encountered a zero divisor error. Set language simplified Chinese begin try declare @ I int = 1 / 0end trybegin catch select ERROR_MESSAGE () as ErrorInfoend catchgo-- found an error divided by zero. Begin try declare @ I int = 1 / 0end trybegin catch select ERROR_MESSAGE () as ErrorInfoend catchgo--0 in set language traditional Chinese is divided into two categories. Set language Japan / begin try declare @ I int = 1 / 0end trybegin catch select ERROR_MESSAGE () as ErrorInfoend catchgo--0 / 0end trybegin catch select ERROR_MESSAGE / as ErrorInfoend catchgo / Japan / 0end trybegin catch select ERROR_MESSAGE / as ErrorInfoend catchgo / Japan / I int = 1 / 0end trybegin catch select ERROR_MESSAGE () as ErrorInfoend catchgo

The result of running the script (take English, Chinese (simplified, traditional), Japanese, Korean (Korean) as examples):

After reading the above, do you have a better understanding of how sql server uses different languages to display error messages? if you want to learn more, you are welcome to follow the industry information channel.

Tags: Language language script Chinese content English different message form data database environment error English reference learning hint operating system English interest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Microsoft OPPO Reno Apple NVidia