Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Towards the innovative SQL ideas
Browse by Tags · View All
ms sql server 119
ms sql 118
sql server 116
sql 115
database 102
tsql 81
#SQL Server 78
t-sql 75
#sql 71
sql server general 67

Archive · View All
April 2011 14
July 2011 12
May 2011 12
August 2011 11
June 2011 10
September 2011 8
December 2011 6
November 2011 6
June 2013 5
April 2013 5

New String functions arrived with SQL Server Denali CTP3

Sep 29 2011 8:53AM by Paresh Prajapati   

I hope you may read my earlier posts for Analytical functions and Conversion functions which are introduced in SQL Server 2011 CTP3. You can also move on What's New of Denali CTP3 here. 

Here i am going to explain new string functions which are also arrived in this SQL Server 11 CTP3 version also.

1. FORMAT:
It returns a formatted values with specified format. It requires three arguments, first is value, second parameter is specified format and last one is culture which is optional. If culture is not provided, it will take default culture. Let us run below queries to get formatted datetime values.It returns resulted output in nvarchar datatype or null.

Let us run some below queries to know it better. First we will run it format for datetime.

DECLARE @DATEVAR DATETIME
SET @DATEVAR =  GETDATE()

SELECT FORMAT( @DATEVAR, 'dd-MM-yyyy') -- 18-07-2011
UNION
SELECT FORMAT( @DATEVAR, 'yyyy-MM-dd', 'en-US' ) -- 2011-07-18
UNION
SELECT FORMAT( @DATEVAR, 'MM-dd-yyyy', 'en-US' ) -- 07-18-2011
UNION
SELECT FORMAT( @DATEVAR, 'MM-dd-yy', 'en-US' ) -- 07-18-11
UNION
SELECT FORMAT( @DATEVAR, 'MM/dd/yy', 'en-US' ) -- 07/18/11
UNION
SELECT FORMAT( @DATEVAR, 'MMddyyyy', 'en-US' ) -- 07182011
UNION
SELECT FORMAT( @DATEVAR, 'yyyy', 'en-US' ) -- 2011
UNION
SELECT FORMAT( @DATEVAR, 'dd', 'en-US' ) -- 18
UNION
SELECT FORMAT( @DATEVAR, 'MM', 'en-US' ) -- 07
UNION
SELECT FORMAT( @DATEVAR, 'hh', 'en-US' ) -- 01
UNION
SELECT FORMAT( @DATEVAR, 'hh:mm', 'en-US' ) -- 01:33
UNION
SELECT FORMAT( @DATEVAR, 'hh:mm:ss', 'en-US' ) -- 01:33:59
UNION
SELECT FORMAT( @DATEVAR, 'MM-dd-yy hh', 'en-US' ) -- 07-18-11 01
UNION
SELECT FORMAT( @DATEVAR, 'MM-dd-yy hh:mm', 'en-US' ) -- 07-18-11 01:33
UNION
SELECT FORMAT( @DATEVAR, 'MM-dd-yy hh:mm:ss', 'en-US' ) -- 07-18-11 01:33:59

GO
Below is the result,
Now will run format function for currency. You can get all currency symbol from here.

DECLARE @money MONEY
SET @money = 50.50

SELECT 'English - United States',FORMAT( @money, 'c', 'en-US' ) 
UNION
SELECT 'Japanese', FORMAT( @money, 'c', 'ja' ) 
UNION
SELECT 'Arabic - Iraq', FORMAT( @money, 'c', 'ar-IQ' ) 
UNION
SELECT 'Icelandic', FORMAT( @money, 'c', 'is' ) 
UNION
SELECT 'Indonesian', FORMAT( @money, 'c', 'id' ) 
UNION
SELECT 'Italian', FORMAT( @money, 'c', 'it' ) 
UNION
SELECT 'Kannada', FORMAT( @money, 'c', 'kn' ) 
UNION
SELECT 'Kazakh', FORMAT( @money, 'c', 'kk' ) 
UNION
SELECT 'Malay', FORMAT( @money, 'c', 'ms' ) 
UNION
SELECT 'Portuguese', FORMAT( @money, 'c', 'pt' ) 
UNION
SELECT 'Russian - Russia', FORMAT( @money, 'c', 'ru-RU' ) 
UNION
SELECT 'Spanish', FORMAT( @money, 'c', 'es' ) 
UNION
SELECT 'Thai', FORMAT( @money, 'c', 'th' ) 

GO


2. CONCAT:
CONCAT(tsql function) which is used to concatenate two or more strings. This function requires 2 to 254 arguments. Let us run below queries to get output with using this function.

SELECT CONCAT('FirstName',' ','LastName' ) 
UNION
SELECT CONCAT('Paresh',' ','Prajapati' )  
UNION
SELECT SUBSTRING(CONCAT('My birthday',':','20111101' ),1,11) 

GO


We can also use CONCAT as computed column.

IF(object_id('EmpDetails','U') > 0)
DROP TABLE EmpDetails

CREATE TABLE EmpDetails
(
EmpId int,
EmpFirstName varchar(50),
EmpLastName varchar(50),
EmpFullname as CONCAT(EmpFirstName,' ',EmpLastName) ,
EmpAddress1 varchar(100),
EmpAddress2 varchar(100),
EmpCity varchar(20),
EmpState varchar(20),
EmpCountry varchar(20),
EmpFullAddress as CONCAT(EmpAddress1,', ',EmpAddress2,', ',EmpCity,', ',EmpState,', ',EmpCountry)
)

INSERT INTO EmpDetails
(
EmpId,
EmpFirstName,
EmpLastName,
EmpAddress1,
EmpAddress2,
EmpCity,
EmpState,
EmpCountry
)
SELECT 
1,
'Paresh',
'Prajapati',
'37- Abhayratna row house',
'NR- Chenpur railway crossing',
'Ahmedabad',
'Gujarat',
'India'

SELECT 
EmpFullname,
EmpFullAddress
FROM EmpDetails

GO



I have drafted some of the just learned tips for FORMAT and CONCAT on www.beyondrelational.com. You can get more tips about SQL Server HERE.

Hope this post will help you.

Tags: sql, tsql, sql server, ms sql, ms sql server, new features, sql server denali, sql server 2011, database, enhancements, SQL Scripts, SQL new features, Denali, CTP, SQL Server 11, JustLearned, query,


Paresh Prajapati
6 · 22% · 7054
3
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"New String functions arrived with SQL Server Denali CTP3" rated 5 out of 5 by 3 readers
New String functions arrived with SQL Server Denali CTP3 , 5.0 out of 5 based on 3 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]