Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScheck_subset_filters

  No additional text.


Syntax

-- Requires Certificate signature for catalog access
create procedure sys.sp_MScheck_subset_filters (@pubid uniqueidentifier
                                        , @use_partition_groups smallint
                                        , @dynamic_filters bit
                                        , @can_use_partition_groups bit output
                                        , @has_dynamic_filters bit output
                                        , @dynamic_filters_function_list nvarchar(500) output
                                        , @uses_host_name bit output
                                        , @uses_suser_sname bit output)
with execute as 'dbo'
as
    declare @retcode int
    , @owner_qualified_art_name nvarchar(400)
    , @art_name nvarchar(130)
    , @viewname sysname
    , @nickname int
    , @objid int
    , @subset_filterclause nvarchar(1000)
    , @found_functions bit


    -- take each subset filter and create a view on the table with a where clause of the subset
    -- filter clause
    select top 1 @nickname = nickname
                , @objid = objid
                , @subset_filterclause = subset_filterclause
    from dbo.sysmergearticles
    where pubid = @pubid
    and subset_filterclause is not null
    and rtrim(ltrim(subset_filterclause)) <> ''
    order by nickname

    while @nickname is not null
    begin

        select @owner_qualified_art_name = quotename(SCHEMA_NAME(schema_id)) + '.' + quotename(name)
                , @art_name = quotename(name)
        from sys.objects
        where object_id = @objid

        select @viewname = quotename('MSmerge_subset_filter_view_' + convert(nvarchar(40), newid()))

        begin tran
        save tran check_subset_filter_partid_lim

        exec ('create view dbo.' + @viewname + ' as select placeholder = 1 from ' + @owner_qualified_art_name + ' ' + @art_name +
                ' where ' + '(' + @subset_filterclause + ')')

        if @@error <> 0
            goto UNDO

        set @found_functions = 0

        exec @retcode = sys.sp_MScheck_functions_directly_in_view    @viewname = @viewname
                                                                , @has_dynamic_filters = @found_functions output
                                                                , @dynamic_filters_function_list = @dynamic_filters_function_list output
                                                                , @uses_host_name = @uses_host_name output
                                                                , @uses_suser_sname = @uses_suser_sname output

        if @@error <> 0 or @retcode <> 0
            goto UNDO

        if @found_functions = 1
        begin
            set @has_dynamic_filters = 1
            --if @dynamic_filters = 0
            --begin
                --raiserror(22517, 16, -1)
                --goto UNDO
            --end
        end

        set @found_functions = 0

        exec @retcode = sys.sp_MScheck_functions_indirectly_in_view @viewname = @viewname
                                                                , @use_partition_groups = @use_partition_groups
                                                                , @can_use_partition_groups = @can_use_partition_groups output
                                                                , @has_dynamic_filters = @found_functions output
                                                                , @dynamic_filters_function_list = @dynamic_filters_function_list output
                                                                , @uses_host_name = @uses_host_name output
                                                                , @uses_suser_sname = @uses_suser_sname output
        if @@error <> 0 or @retcode <> 0
            goto UNDO

        if @found_functions = 1
        begin
            set @can_use_partition_groups = 0
            set @has_dynamic_filters = 1

            if @use_partition_groups in (1,2)
            begin
                -- no need to raise new error. sp_MScheck_functions_indirectly_in_view would have
                -- raised an error if it had found any functions.
                goto UNDO
            end
            --if @dynamic_filters = 0
            --begin
                --raiserror(22517, 16, -1)
                --goto UNDO
            --end
        end

        -- rollback tran so that the temp view gets dropped.
        rollback tran check_subset_filter_partid_lim
        commit tran

        -- Check the next subset filter.

        select top 1 @nickname = nickname
                , @objid = objid
                , @subset_filterclause = subset_filterclause
        from dbo.sysmergearticles
        where pubid = @pubid
        and subset_filterclause is not null
        and rtrim(ltrim(subset_filterclause)) <> ''
        and nickname > @nickname
        order by nickname

        if @@rowcount = 0
            set @nickname = NULL
    end

    return 0

UNDO:

    if @@trancount > 0
    begin
        rollback tran check_subset_filter_partid_lim
        commit tran
        return 1
    end

 
Last revision 2008RTM
See also

  sp_MScheck_dynamic_filters (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