Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

sys.dm_sql_referenced_entities Expand / Collapse
Author
Message
Posted Monday, March 25, 2013 6:40 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 25, 2013 6:42 PM
Points: 1, 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.
Post #1435214
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse