SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


sys.dm_sql_referenced_entities


sys.dm_sql_referenced_entities

Author
Message
Developer Man
Developer Man
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 3
Hi buddies!

I'm in troubles with a query, when I execute the next statement SQL returns a set of rows:

SELECT * FROM sys.dm_sql_referenced_entities('dbo.MySp', 'OBJECT')

But, when I use sys.dm_sql_referenced_entities inside a User Defined Function, SQL returns always nothing:

CREATE FUNCTION getDependencyActionType
(
@FullObjectName AS NVARCHAR(1000)
)
RETURNS NVARCHAR(10)
AS
BEGIN
DECLARE
@SELECT INT,
@SELECTALL INT,
@UPDATE INT,
@RESULT NVARCHAR(10)

SELECT @SELECT = COUNT(CASE
WHEN E.is_selected = 1 THEN
1
ELSE
NULL
END)
,@SELECTALL = COUNT(CASE
WHEN E.is_select_all = 1 THEN
1
ELSE
NULL
END)
,@UPDATE = COUNT(CASE
WHEN E.is_updated = 1 THEN
1
ELSE
NULL
END)
FROM sys.dm_sql_referenced_entities(@FullObjectName, 'OBJECT') E


IF ISNULL(@UPDATE, 0) > 0
SET @RESULT = 'I/D/U'
ELSE IF ISNULL(@SELECTALL, 0) > 0
SET @RESULT = 'SELECT *'
ELSE
SET @RESULT = 'SELECT'

RETURN @RESULT

END

GO

SELECT dbo.getDependencyActionType('dbo.MySp')

--And the result is nothing :'(



Please, help me.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search