Constants in Query Result Sets

Constants are not usually specified as a separate column in a result set. It is usually more efficient for an application itself to build the constant value into the results when they are displayed, rather than requiring the server to incorporate the constant value in every result set row returned across the network.

Exceptions to this general rule include:

Character string constants are included for proper formatting or readability when character columns are concatenated. This example combines the LastName and FirstName columns into a single column. The character string ‘, ‘ separates the two parts of the name in the new combined column:

SELECT LastName + ', ' + FirstName AS EmployeeName

FROM Northwind.dbo.Employees

ORDER BY LastName, FirstName ASC

  

See Also
+ (Add) String Concatenation Operator
SELECT  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.