LITERAL in SQL Server
The article details how to use Literal - Hang (strings, integers, decimals, and datetime values) in SQL Server.
The article will guide you in detail how to use Literal - Hang (strings, integers, decimals, and datetime values) in SQL Server.
Literal Description (Hang)
In SQL Server, Literal relates to fixed values that the program cannot change. Literal can be any type of value, specifically divided into string constant values, integer constants, real constants, and time constant values.
String Literals - Hang String
Sequence of strings is always in single quotes.
'quantrimang.com'
'ABC'
'123'
The example above contains separate strings within each pair of single quotes. However, there is a case in the string that also contains an apostrophe. For example:
'quantrimang.com is very great! It's my favorite site! '
In this example, the string contains an apostrophe in the word It. This single quotation mark makes the break statement in the second parenthesis as follows:
'quantrimang.com is very great! It '
To resolve this error to avoid subsequent commands, you need to add a similar single quotation mark to escape from it:
'quantrimang.com is very great! It''s my favorite site! '
Integer Literals - Constant integer
Integer constants include negative integers and positive integers, not including decimals. If you don't specify a specific marker, the program will default to your constant as positive. Representing valid integer constants is as follows:
2018
+2018
-2018
Decimals Literals - Real Constant
The real constant includes negative integers, positive integers and even decimal numbers. If you don't specify a specific marker, the program will default to your constant as positive. Representing valid real constants is as follows:
2018,11
+2018,11
-2018,11
Datetime Literals - Hang Value time
Time value constant is always placed in single quotes, represented as follows:
'November 06, 2018'
'2018/11/06'
'2018/11/06 12:24:48'
Previous article: Use annotations in SQL Server
Next article: Declaring variables in SQL Server
You've just finished reading the article "LITERAL in SQL Server" edited by the TipsMake team. You can save literal-in-sql-server.pdf to your computer here to read later or print it out. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.
- Network basics: Part 3 - DNS Server
- Complex String Slice in Golang
- How to set up your own Git server on Linux
- Use IIS to set up FTP Server on Windows
- How to change DNS server on the most popular routers
- What is VPS? VPS used to do? What is VPS different from Server?
- 7 great ideas using Raspberry Pi as a server
- New points in SQL Server 2017
- Instructions for setting up and managing FTP Server on Windows 10
- Create VPN Server on Windows 8
- What is the future of server virtualization?
- Learn about the architecture of MS SQL Server
- Instructions for installing MS SQL Server
- How to install DNS Server on Windows Server 2019