Sunday, February 17, 2013

SQL SERVER SPACE String function

SQL SERVER SPACE String function

 Space String function adds space between Strings.

Ex: Concat unicode Strings using SPACE String function
select concat(N'Ich',space(1),'komme',space(1),'aus',space(1),'Deutschland') german
O/P:
german
Ich komme aus Deutschland
 Ex:Concat strings using Space String function
select concat(N'I',space(1),'am',space(1),'from',space(1),'germany') english
O/P:  
english
I am from germany

Ex: Replace telephone numbers separator -  with  spaces

declare @telehpne char(12)
set @telehpne='409-345-4356'
set @telehpne=replace(@telehpne,'-',space(1))
select @telehpne


O/P:  409 345 4356

Tags: SQL Server Concat String function,SQL Server Space String function,T-SQL concat,Concat 2 numeric literals in SQL Server,Concat Unicode chars in SQL Server,Concat Ascii chars in SQL Server

No comments:

Post a Comment