sql server 2008 - Getting tables used inside User Defined Functions -
Is it possible to retrieve all the tables and views used in a user defined function? Is there a defined process to go through udf name?
function sample_function To create return table, select Table 1 from t1 to join table2 t2 to t2.id = t1.id
me Table1
and table2
are needed when I can pass sample_function
in any process.
Any ideas will help
Hope this will be helpful. Edit
Edit: To get only the referenced tables, select
Choose from DISTINCT referenced_net_name to sys.dm_sql_referenced_entities ('Dbo.fn_sample', 'OBJECT') Use the query below Select referenced_neti_name sys .dm_sql_referenced_entities ('dbo.fn_sample', 'OBJECT') join the sysobjects at ro INNER (ro.referenced_id = so.id) where SO.xtype = 'U'
Comments
Post a Comment