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

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile