What Is a Constant or Literal in MS SQL Server?
Submitted by: AdministratorA constant, or literal, is a symbol that represents a specific value of a specific data type. Constants or literals are used commonly as the default values for table columns, variables, and parameters. The format of constant or literal depends on the data type of the value it represents. There are x formats used to specify literals in SQL Server:
* Integer Number Literals - Strings of numbers prefixed with (+/-) as the sign if needed. They are used for integer data types. For example: -2255.
* Decimal Number Literals - Strings of numbers with a single decimal point and an optional prefix sign (+/-). They are used for DECIMAL data type. For example: 1894.1204.
* Floating Point Number Literals - Numeric values represented in the scientific notation. They are used for FLOAT data type. For example: 9.22337e+010.
* Character String Literals - Strings of characters enclosed in single quotes. They are used for character string data types. . For example: 'Welcome to GlobalGuideLine.com!'.
* Unicode Character String Literals - Strings of Unicode characters enclosed in single quotes with a prefix of (N). They are used for Unicode character string data types. For example: N'Welcome to GlobalGuideLine.com'.
Submitted by: Administrator
* Integer Number Literals - Strings of numbers prefixed with (+/-) as the sign if needed. They are used for integer data types. For example: -2255.
* Decimal Number Literals - Strings of numbers with a single decimal point and an optional prefix sign (+/-). They are used for DECIMAL data type. For example: 1894.1204.
* Floating Point Number Literals - Numeric values represented in the scientific notation. They are used for FLOAT data type. For example: 9.22337e+010.
* Character String Literals - Strings of characters enclosed in single quotes. They are used for character string data types. . For example: 'Welcome to GlobalGuideLine.com!'.
* Unicode Character String Literals - Strings of Unicode characters enclosed in single quotes with a prefix of (N). They are used for Unicode character string data types. For example: N'Welcome to GlobalGuideLine.com'.
Submitted by: Administrator
* Unicode Character String Literals - Strings of Unicode characters enclosed in single quotes with a prefix of (N). They are used for Unicode character string data types. For example: N'Welcome to GlobalGuideLine.com'.
* Binary String Literals - Strings of bytes expressed in HEX numbers and prefixed with (0x). They are used for binary string data types. For example: '0x69048AEFDD010E'.
* Date and Time Literals - Data and time values expressed in several popular formats and enclosed in single quotes ('). They are used for data and time data types. For example: '2007-05-19 22:55:07.233'.
* Money Literals - Strings of numbers with a single decimal point with a prefix of ($) and optional sign (+/-). They are used for money data types. For example: $542023.14.
Submitted by: Administrator
* Binary String Literals - Strings of bytes expressed in HEX numbers and prefixed with (0x). They are used for binary string data types. For example: '0x69048AEFDD010E'.
* Date and Time Literals - Data and time values expressed in several popular formats and enclosed in single quotes ('). They are used for data and time data types. For example: '2007-05-19 22:55:07.233'.
* Money Literals - Strings of numbers with a single decimal point with a prefix of ($) and optional sign (+/-). They are used for money data types. For example: $542023.14.
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Start SQL Server Browser Service? |
☺ | How To Execute the Cursor Queries with "OPEN" Statements? |
☺ | How To Test ODBC DSN Connection Settings? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
☺ | How To Create a Testing Table with Test Data in MS SQL Server? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |