Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Concat_ws
Message
 
 
À
27/05/2006 03:38:08
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01125483
Message ID:
01125578
Vues:
19
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform