Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Concat_ws
Message
 
 
To
27/05/2006 03:38:08
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01125483
Message ID:
01125578
Views:
14
Winan,

>At MySQL I can use concat_ws for Concatenate With Separator .. what is similar function of concat_ws in SQL server? ..
create function concat_ws( 
 @separator varchar(254),
 @str1 varchar(1024) = null,
 @str2 varchar(1024) = null,
 @str3 varchar(1024) = null,
 @str4 varchar(1024) = null,
 @str5 varchar(1024) = null,
 @str6 varchar(1024) = null
 )
 returns varchar(8000)
as
begin
declare @cRetval varchar(8000)
set @cRetval = ''
if ( @str1 is not null )
   set @cRetVal = @str1
if ( @str2 is not null )
   set @cRetVal = @cRetval + @separator + @str2
if ( @str3 is not null )
   set @cRetVal = @cRetval + @separator + @str3
if ( @str4 is not null )
   set @cRetVal = @cRetval + @separator + @str4
if ( @str5 is not null )
   set @cRetVal = @cRetval + @separator + @str5
if ( @str6 is not null )
   set @cRetVal = @cRetval + @separator + @str6

return @cRetval
end
to use it:
select dbo.concat_ws( ',', 'one', '1', 'uno', default, default, default )
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform