Skip to content

Latest commit

 

History

History
200 lines (125 loc) · 7.67 KB

File metadata and controls

200 lines (125 loc) · 7.67 KB
title Updated - T-SQL docs | Microsoft Docs
description Display snippets of updated content for recently changed in documentation, for Transact-SQL.
services na
documentationcenter
author MightyPen
manager jhubbard
editor BYHAM
ms.service na
ms.topic updart-autogen
ms.technology database-engine
ms.custom UpdArt.exe
ms.tgt_pltfrm na
ms.devlang na
ms.date 09/11/2017
ms.author genemi
ms.workload t-sql

New and Recently Updated: Transact-SQL docs

Nearly every day Microsoft updates some of its existing articles on its Docs.Microsoft.com documentation website. This article displays excerpts from recently updated articles. Links to new articles might also be listed.

This article is generated by a program that is rerun periodically. Occasionally an excerpt can appear with imperfect formatting, or as markdown from the source article. Images are never displayed here.

Recent updates are reported for the following date range and subject:

  • Date range of updates:   2017-07-18   -to-   2017-09-11
  • Subject area:   T-SQL.

 

New Articles Created Recently

The following links jump to new articles that have been added recently.

  1. PREDICT (Transact-SQL)
  2. ALTER EXTERNAL LIBRARY (Transact-SQL)
  3. CREATE EXTERNAL LIBRARY (Transact-SQL)
  4. DROP EXTERNAL LIBRARY (Transact-SQL)

 

Updated Articles with Excerpts

This section displays the excerpts of updates gathered from articles that have recently experienced a large update.

The excerpts displayed here appear separated from their proper semantic context. Also, sometimes an excerpt is separated from important markdown syntax that surrounds it in the actual article. Therefore these excerpts are for general guidance only. The excerpts only enable you to know whether your interests warrant taking the time to click and visit the actual article.

For these and other reasons, do not copy code from these excerpts, and do not take as exact truth any text excerpt. Instead, visit the actual article.

 

This compact list provides links to all the updated articles that are listed in the Excerpts section.

  1. CAST and CONVERT (Transact-SQL)

 

 

Updated: 2017-09-08          

 

K. Using CAST with arithmetic operators

The following example calculates a single column computation by dividing the product unit price (UnitPrice) by the discount percentage (UnitPriceDiscountPct). This result is converted to an int data type after being rounded to the nearest whole number. Uses AdventureWorksDW.

SELECT ProductKey, UnitPrice,UnitPriceDiscountPct,
       CAST(ROUND (UnitPrice*UnitPriceDiscountPct,0) AS int) AS DiscountPrice
FROM dbo.FactResellerSales
WHERE SalesOrderNumber = 'SO47355'
      AND UnitPriceDiscountPct > .02;

..!NCLUDE-NotShown--ssResult--../../includes/ssresult-md.md)]

ProductKey  UnitPrice  UnitPriceDiscountPct  DiscountPrice
----------  ---------  --------------------  -------------
323         430.6445   0.05                  22
213         18.5043    0.05                  1
456         37.4950    0.10                  4
456         37.4950    0.10                  4
216         18.5043    0.05                  1

L. Using CAST to concatenate

The following example concatenates noncharacter expressions by using CAST. Uses AdventureWorksDW.

SELECT 'The list price is ' + CAST(ListPrice AS varchar(12)) AS ListPrice
FROM dbo.DimProduct
WHERE ListPrice BETWEEN 350.00 AND 400.00;

..!NCLUDE-NotShown--ssResult--../../includes/ssresult-md.md)]

ListPrice
------------------------
The list price is 357.06
The list price is 364.09
The list price is 364.09
The list price is 364.09
The list price is 364.09

M. Using CAST to produce more readable text

The following example uses CAST in the SELECT list to convert the Name column to a char(10) column. Uses AdventureWorksDW.

SELECT DISTINCT CAST(EnglishProductName AS char(10)) AS Name, ListPrice
FROM dbo.DimProduct
WHERE EnglishProductName LIKE 'Long-Sleeve Logo Jersey, M';

..!NCLUDE-NotShown--ssResult--../../includes/ssresult-md.md)]

Similar Articles

This section lists very similar articles for recently updated articles in other subject areas, within our public GitHub.com repository: MicrosoftDocs/sql-docs.

Subject areas which do have new or recently updated articles

Subject areas which have no new or recently updated articles