loading..
Русский    English
12:18

Renaming the columns and calculations in the result set page 2

SQL Standard allows to use delimited identifier, whereas delimiter is the double quote - ("). If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it. For example, the query

Console
Execute
  1. SELECT 'SELECT' "SELECT"
returns expression value (character constant 'SELECT' in our case) in the column named SELECT, i.e. we use a keyword as a column name. Otherwise the compiler (SQL Server) does not correctly parse the following query

Console
Execute
  1. SELECT 'SELECT' SELECT
and the error arises:

Incorrect syntax near 'SELECT'.

Apart from standard delimiter, nearly each DBMS adopts the own  one.  For example, the above query in  A database management system (DBMS) by Microsoft Corporation. SQL(Structured Query Language) is a database computer language designed for the retrieval and management of data in relational database management systems (RDBMS), database schema creation and modification, and database object access control management.SQL Server can be written as

Console
Execute
  1. SELECT 'SELECT' [SELECT]

The both delimiters - standard and own - can be used simultaneously, but the standard one not always is supported by default. The proper setting parameter in MSSQL can be changed with the statement:

  1. SET QUOTED_IDENTIFIER { ON | OFF }
The standard behaviour (ON) is assumed by default here.

Bookmark and Share
Pages 1 2 3
Tags
aggregate functions Airport ALL AND AS keyword ASCII AVG Battles Bezhaev Bismarck C.J.Date calculated columns Cartesian product CASE cast CHAR CHARINDEX Chebykin check constraint classes COALESCE common table expressions comparison predicates Computer firm CONSTRAINT CONVERT correlated subqueries COUNT CROSS APPLY CTE data type conversion data types database schema DATEADD DATEDIFF DATENAME DATEPART DATETIME date_time functions DDL DEFAULT DEFAULT VALUES DELETE DISTINCT DML duplicates edge equi-join EXCEPT exercise (-2) More tags
The book was updated
month ago
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.