SQL Server ed ALM su database


Il blog di Alessandro Alpi
Archivio Posts
Anno 2018

Anno 2017

Anno 2016

Anno 2015

Anno 2014

Anno 2013

Anno 2012

Anno 2011

Anno 2010

Anno 2009

Anno 2008

Anno 2007

Anno 2006

SQL Server Denali - Transact-SQL - String Functions - FORMAT e CONCAT

Continuiamo la carrellata dei nuovi comandi del Transact SQL su SQL Server 2011.
Dopo aver parlato di altre importanti funzioni e statement come quelli descritte in un paio di post precedenti qui e qui, spostiamoci su un classico, le stringhe.
La nuova versione di T-SQL porterà importanti attesissime aggiunte, come la FORMAT e la CONCAT



La FORMAT consente di formattare un particolare valore in un ben preciso formato supportato dal framework (ad esempio il "d" per le date, il "c" per le currency) in base alla cultura, definita nell'ultimo parametro (facoltativo). Non aspettatevi però il composite formatting, poichè purtroppo non supportato. Per una lista delle formattazioni supportate potete leggere nei link qui di seguito:

Standard numeric format stings

Standard date and time format strings

CONCAT concatena un numero variabile di valori, il cui tipo non necessariamente stringa viene implicitamente convertito appunto, in stringa.
Il tipo di ritorno varia in base alla seguente tabella:

Input type

Output type and length

If any argument is a SQL-CLR system type, a SQL-CLR UDT, or nvarchar(max)

nvarchar(max)

Otherwise, if any argument is varbinary(max) or varchar(max)

varchar(max)

unless one of the parameters is an nvarchar of any length. If so, then the result is nvarchar(max).

Otherwise, if any argument is nvarchar(<= 4000)

nvarchar(<= 4000)

Otherwise, in all other cases

varchar(<= 8000)

unless one of the parameters is an nvarchar of any length. If so, then the result is nvarchar(max).



Stay Tuned! 

Categoria: SQL Server 2012
martedì, 11 ott 2011 Ore. 00.01

Messaggi collegati


Statistiche
  • Views Home Page: 585.121
  • Views Posts: 1.042.205
  • Views Gallerie: 609.371
  • n° Posts: 484
  • n° Commenti: 273



















Copyright © 2002-2007 - Blogs 2.0
dotNetHell.it | Home Page Blogs
ASP.NET 2.0 Windows 2003