LITERAL 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

4.5 ★ | 2 Vote

May be interested

  • Instructions for setting up and managing FTP Server on Windows 10Instructions for setting up and managing FTP Server on Windows 10
    if you want to create a private cloud for sharing and converting large files without restrictions, you can create an ftp server (file transfer protocol server) on your windows 10 computer.
  • Create VPN Server on Windows 8Create VPN Server on Windows 8
    no need to install any additional applications, you can easily 'turn' your computer into a vpn server if you're using windows 8. in this way, you can share data from the computer. as a simple lan system in the form of remote access. & a
  • What is the future of server virtualization?What is the future of server virtualization?
    server virtualization can help combat poor server performance, make better use of computing capabilities, limit energy consumption and improve data center flexibility.
  • Learn about the architecture of MS SQL ServerLearn about the architecture of MS SQL Server
    in the previous articles, you already know briefly about sql server, how to install sql server on the computer. in this section we will learn about the architecture of sql server.
  • Instructions for installing MS SQL ServerInstructions for installing MS SQL Server
    this is a step by step guide to installing ms sql server.
  • How to install DNS Server on Windows Server 2019How to install DNS Server on Windows Server 2019
    from microsoft, the domain name system (dns) is one of the industry standard protocol sets that includes tcp / ip, along with dns client and dns server that provide name resolution services that map names to the ip addresses of computers. .
  • Install Windows Server 2003 and create a backup serverInstall Windows Server 2003 and create a backup server
    network management documentation server 2003 as details of how to install, create a companion server in case the main server is malfunctioning, create a domain, join the client to the domain, the conection {remote desktop from the client data to server}, set adsl router parameters to server, turn off 1 working machine immediately.
  • Instructions to change DNS Server on Windows, Mac, iOS and AndroidInstructions to change DNS Server on Windows, Mac, iOS and Android
    by default, your computer will automatically obtain dns information from your isp (isp). sometimes, dns servers are unstable and you are blocked from accessing certain websites. or the default dns server is blocked by some websites for a number of reasons. in this case you should change the dns server with the free public dns server.
  • How to configure DNS Server on Ubuntu Server 11.04How to configure DNS Server on Ubuntu Server 11.04
    dns server is a server with domain name resolution function. in this article, we will detail the steps to install and configure dns server on linux with ubuntu server version 11.04.
  • Instructions for setting up individual FTP Server with FileZillaInstructions for setting up individual FTP Server with FileZilla
    unlike http - designed to forward hyper - text data over tcp connections, standard ftp ensures that the server responds to requests as soon as it receives a signal from the host. not only provides fast and accurate file transfer, but also security, gives users more options in the process of downloading and uploading data ...