Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScheck_functions_indirectly_in_view

  No additional text.


Syntax
-- Requires Certificate signature for catalog access
create procedure sys.sp_MScheck_functions_indirectly_in_view @viewname nvarchar(400)
                                                            , @use_partition_groups smallint
                                                            , @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
as
    declare @depends_on_viewid int
    , @owner_qualified_depends_on_viewname nvarchar(400)
    , @retcode int


    select top 1 @depends_on_viewid = referenced_major_id
    from sys.sql_dependencies
    where object_id = object_id(@viewname)
    and referenced_major_id in (select object_id from sys.objects where type = 'V')
    order by referenced_major_id

    while @depends_on_viewid is not null
    begin

        select @owner_qualified_depends_on_viewname = quotename(SCHEMA_NAME(schema_id)) + '.' + quotename(name)
        from sys.objects
        where object_id = @depends_on_viewid

        exec @retcode = sys.sp_MScheck_functions_directly_in_view    @viewname = @owner_qualified_depends_on_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
            return 1

        if @has_dynamic_filters = 1
        begin
            set @can_use_partition_groups = 0

            if @use_partition_groups in (1,2)
            begin

                -- View @owner_qualified_depends_on_viewname contains functions and is
                -- referenced in a filter clause.
                raiserror(22514, 16, -1, @owner_qualified_depends_on_viewname)
                return 1
            end

        end

        exec @retcode = sys.sp_MScheck_functions_indirectly_in_view @viewname = @owner_qualified_depends_on_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
            return 1

        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.
                return 1
            end
        end

        select top 1 @depends_on_viewid = referenced_major_id
       from sys.sql_dependencies
        where object_id = object_id(@viewname)
        and referenced_major_id in (select object_id from sys.objects where type = 'V')
        and referenced_major_id > @depends_on_viewid
        order by referenced_major_id

        if @@rowcount = 0
            select @depends_on_viewid = NULL
    end

    return 0

 
Last revision 2008RTM
See also

  sp_check_join_filter (Procedure)
sp_check_subset_filter (Procedure)
sp_MScheck_join_filters (Procedure)
sp_MScheck_subset_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