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 should read it
- Hang (Constant / Literal) in C / C ++
- Constant in programming C
- Constants in PHP
- DAY function in SQL Server
- The difference between web server and app server
- Network basics: Part 3 - DNS Server
- DATEPART function in SQL Server
- SEQUENCE in SQL Server
- FLOOR function in SQL Server
- New points in SQL Server 2017
- SQL Server 2019 - Microsoft Relational Database Management System
- CEILING function in SQL Server
Maybe you are interested
5 quietest keyboards Why the foundation of the world's tallest tower Burj Khalifa must be powered 24/7 Invite to download the space theme wallpapers on the NASA XS inspired by NASA If we bring a part of the Sun to Earth, what terrible thing will happen? The Earth's core and the Sun's surface, which is hotter? Terrifying scenario if the Earth lost oxygen in 5 seconds?