Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScheck_join_filters

  No additional text.


Syntax
-- Requires Certificate signature for catalog access
create procedure sys.sp_MScheck_join_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 @join_filterid int
    , @art_nickname int
    , @join_nickname int
    , @join_filterclause nvarchar(1000)
    , @join_objid int
    , @art_objid int
    , @owner_qualified_art_name nvarchar(400)
    , @owner_qualified_join_name nvarchar(400)
    , @art_name nvarchar(130)
    , @join_name nvarchar(130)
    , @viewname sysname
    , @retcode int


    -- take each join filter and create a view between the parent and child tables
    -- using the join filter as the join clause.
    select top 1 @join_filterid = join_filterid
                , @art_nickname = art_nickname
                , @join_nickname = join_nickname
                , @join_filterclause = join_filterclause
    from dbo.sysmergesubsetfilters
    where pubid = @pubid
    and (filter_type & 1) = 1
    order by join_filterid

    while @join_filterid is not null
    begin
        select @join_objid = objid from dbo.sysmergearticles where nickname = @join_nickname
        select @art_objid = objid from dbo.sysmergearticles where nickname = @art_nickname

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

        select @owner_qualified_join_name = quotename(SCHEMA_NAME(schema_id)) + '.' + quotename(name)
                , @join_name = quotename(name)
        from sys.objects
        where object_id = @join_objid

        select @viewname = quotename('MSmerge_join_filter_view_' + convert(nvarchar(40), newid()))
        select @viewname = REPLACE(@viewname, '-', '_')

        begin tran
        save tran check_join_filter_partid_lim

        exec ('create view dbo.' + @viewname + ' as select placeholder = 1 from ' + @owner_qualified_art_name + ' ' + @art_name + ', ' +
                    @owner_qualified_join_name + ' ' + @join_name + ' where ' + '(' + @join_filterclause + ')')
        if @@error <> 0
            goto UNDO

        exec @retcode = sys.sp_MScheck_functions_directly_in_view    @viewname = @viewname
                                                                , @has_dynamic_filters = @has_dynamic_filters 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 @has_dynamic_filters = 1
        begin

            set @can_use_partition_groups = 0

            if @use_partition_groups in (1,2)
            begin
                --Join filter between art_name and join_name contains functions
                raiserror(22513, 16, -1, @owner_qualified_art_name, @owner_qualified_join_name)
                goto UNDO
            end

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

        end

        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 = @has_dynamic_filters 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 @has_dynamic_filters = 1
        begin
            set @can_use_partition_groups = 0

            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_join_filter_partid_lim
        commit tran

        -- Check the next join filter.

        select top 1 @join_filterid = join_filterid
                , @art_nickname = art_nickname
                , @join_nickname = join_nickname
                , @join_filterclause = join_filterclause
        from dbo.sysmergesubsetfilters
        where pubid = @pubid
        and (filter_type & 1) = 1
        and join_filterid > @join_filterid
        order by join_filterid

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

    return 0

UNDO:

    if @@trancount > 0
    begin
        rollback tran check_join_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