Wednesday, 18 February 2015

New String Functions in SQL Server 2012

String Functions

FORMAT Function
The format function is used to format how a field is to be displayed.

Format converts the first argument to a specified format and returns the string value.

Declare @d DateTime=’20/03/2011’
Select Format(@d,’d’,’en-US’) as US_Result

This function formats the datetime. this function is used in the server .NET Framework and CLR. The function will solve many formatting issues for developers.

CONCAT Function
It’s the same concatenate function that we use in Excel; it will concatenate two or more strings to make it single string. It implicitly converts all arguments to string types.

CONCAT(string_value1,string_value2,- - - - ,[string_valueN])
String_value: A String value to concatenate to the other values.

Select concat(‘rock’,’-’,’smith’) as Concatestring

This function expects at least two parameters and a maximum of 254 parameters.

No comments:

Post a Comment