Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSisdynamicfunction

  No additional text.


Syntax

create procedure sys.sp_MSisdynamicfunction @functionname sysname, @isdynamic bit output, @uses_host_name bit output
															, @uses_suser_sname bit output
    as
    begin

    declare @function_id int, @retcode int, @name nvarchar(270), @object_id int

    select @function_id = object_id(@functionname), @isdynamic = 0

    if @function_id is null
		return 1
		
	-- a function is considered dynamic if
	-- (1) it references views. we should really expand the views and see if they have a dynamic function
	-- hidden somewhere - but this will make the checking code to be too complex. It is easier to assume that
	-- a UDF referencing a view is dynamic. This is an extremely rare case anyway.
	-- (2) it references other functions which are dynamic, or
	-- (3) it has host_name() or suser_sname() or other server built-in functions in its text.

    if exists (select * from sys.objects where object_id in
				(
				select referenced_major_id
				from sys.sql_dependencies where object_id = @function_id
				and referenced_major_id in (select object_id from sys.objects where type = 'V')
				)
			   )
	begin
		select @isdynamic = 1
		return 0
	end
		
	select top 1 @object_id = object_id, @name = schema_name(schema_id) + '.' + name
	from sys.objects where object_id in
		(	
		select referenced_major_id
		from sys.sql_dependencies where object_id = @function_id
		and referenced_major_id in (select object_id from sys.objects where type = 'FN')
		)
	order by object_id
	
	while @object_id is not null
	begin
					
		exec @retcode = sys.sp_MSisdynamicfunction @name, @isdynamic output, @uses_host_name output, @uses_suser_sname output
		if @retcode <> 0 or @@error <> 0
			return 1
			
		if @isdynamic = 1
			return 0
	
		select top 1 @object_id = object_id, @name = schema_name(schema_id) + '.' + name
		from sys.objects where object_id in
			(	
			select referenced_major_id
			from sys.sql_dependencies where object_id = @function_id
			and referenced_major_id in (select object_id from sys.objects where type = 'FN')
			)
		and object_id > @object_id
		order by object_id
	
		if @@rowcount = 0
			select @object_id = NULL
	end
		
	exec @retcode = sys.sp_UDFhas_builtin_functions @functionname, @isdynamic output, @uses_host_name output, @uses_suser_sname output
	
    return @retcode

    end

 
Last revision 2008RTM
See also

  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