PHP SQL Server – Constants in Query Result Sets

PHP SQL Server – 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:

  • Stored procedures may be called by many different applications or scripts. These procedures do not have access to the constant value that should be incorporated in the results. The SELECT statement in the procedure itself should then specify the constant as part of the select list.
  • When a site wants to enforce a formatting or display standard, the format can be built into a view or stored procedure.
  • A SELECT statement may be executed from a script or a tool that does not support merging constants with a result set after the result set has been returned from the server.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">