Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSget_distinct_semicolon_sep_items

  No additional text.


Syntax

create procedure sys.sp_MSget_distinct_semicolon_sep_items @dynamic_filters_function_list nvarchar(500) output
as
    declare @function_list_table table (function_name sysname)
    declare @function_list_table_distinct table (function_name sysname)
    declare @cur_index int
    , @prev_index int
    , @function sysname
    , @datalength int

    if @dynamic_filters_function_list is null or @dynamic_filters_function_list = ' '
        return 0

    select    @datalength = datalength(@dynamic_filters_function_list)/2,
            @prev_index = 1,
            @cur_index = charindex (';', @dynamic_filters_function_list, @prev_index)

    while (@cur_index <> 0)
    begin
        select @function = substring(@dynamic_filters_function_list, @prev_index, @cur_index - @prev_index)
        select @function = REPLACE(REPLACE(REPLACE(REPLACE(@function collate SQL_Latin1_General_CP1_CS_AS, char(0x20),''), char(0x09),''), char(0x0D),''), char(0x0A),'')
        if (ltrim(rtrim(@function)) <> ' ')
        begin
            insert into @function_list_table values (@function)
        end
        select @prev_index = @cur_index+1
        select @cur_index = 0
        select @cur_index = charindex (';', @dynamic_filters_function_list, @prev_index)
    end

    -- still need to get the last one

    if (@datalength > @prev_index)
    begin
        select @function = substring(@dynamic_filters_function_list, @prev_index, @datalength - @prev_index + 1)
        select @function = REPLACE(REPLACE(REPLACE(REPLACE(@function collate SQL_Latin1_General_CP1_CS_AS, char(0x20),''), char(0x09),''), char(0x0D),''), char(0x0A),'')
        if (ltrim(rtrim(@function)) <> ' ')
        begin
            insert into @function_list_table values (@function)
        end
    end

    -- Now that we have read all values out of @dynamic_filters_function_list, we can reuse it
    -- to send the distinct values back. Set it to NULL initially.
    set @dynamic_filters_function_list = NULL

    -- Order the result set by datalength desc, so that the larger names are at the front of the list, and the shorter
    -- ones towards the end. This fixes some problems with textual substitutions when one function name is contained
    -- in another.
    insert into @function_list_table_distinct (function_name)
    select distinct function_name collate SQL_Latin1_General_CP1_CI_AS from @function_list_table

     declare distinct_function_names cursor local fast_forward for
    select function_name from @function_list_table_distinct
    order by len(function_name) desc
    for read only

    open distinct_function_names

    fetch next from distinct_function_names into @function
    while @@fetch_status <> -1
    begin
        if @dynamic_filters_function_list is null
            set @dynamic_filters_function_list = @function
        else
            set @dynamic_filters_function_list = @dynamic_filters_function_list + ';' + @function

        fetch next from distinct_function_names into @function
    end

    return 0

 
Last revision 2008RTM
See also

  sp_MScheck_dynamic_filters (Procedure)
sp_MScheck_functions_directly_in_view (Procedure)
sp_MSdrop_rladmin (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash