zoukankan      html  css  js  c++  java
  • 函數返回一個用分隔符連接起的字符串,其中每個單位的字符串不重復存在

    /****************************************************************************************************************************
    Name:   ufn_SerialString  

    Description: 函數返回一個用分隔符連接起的字符串,其中每個單位的字符串不重復存在

    Parameters:   IN - @strBase - 連接在一起的字符串
         IN - @strNew - 新加入的字符串
         IN - @strSplitChar - 分隔符

    Return:   連接在一起的字符串

    Usage:   create table #temp(strValue varchar(10))
        insert #temp select 'a'
        union all select 'b'
        union all select 'c'
        union all select 'b'
        union all select 'a'
        select strValue as N'原始數據' from #temp
        declare @str varchar(1000)
        select @str=dbo.ufn_SerialString(@str,strValue,',') from #temp
        print '===================================================================================='
        select @str as N'連接之後的字符串'
        drop table #temp

    Calling functions:    System     Module

    ****************************************************************************************************************************/
    CREATE FUNCTION [dbo].[ufn_SerialString] (@strBase NVARCHAR(4000),
          @strNew NVARCHAR(4000),
          @strSplitChar NVARCHAR(1)='/')
    RETURNS NVARCHAR(4000) AS
    BEGIN
    SET @strBase=RTRIM(ISNULL(@strBase,''))
    SET @strNew=RTRIM(ISNULL(@strNew,''))
    SET @strBase=CASE WHEN @strBase='' THEN @strNew
       WHEN @strNew='' OR CHARINDEX(@strSplitChar+@strNew+@strSplitChar,@strSplitChar+@strBase+@strSplitChar)>0 THEN @strBase
       ELSE @strBase+@strSplitChar+@strNew END
    RETURN @strBase
    END

  • 相关阅读:
    iOS:后台定位并实时向服务器发送位置
    iOS:创建Siri 功能
    Cocoa编程开发者手册
    iOS应用开发最佳实践
    Linux Shell编程与编辑器使用详解
    从虚拟化到云计算
    软件集成策略——如何有效率地提升质量
    水色物语:清新水彩手绘插画技法
    易用为王:改进产品设计的10个策略
    iOS Web应用开发:运用HTML5、CSS3与JavaScript
  • 原文地址:https://www.cnblogs.com/guyuehuanhuan/p/1942274.html
Copyright © 2011-2022 走看看