Enhancement to OBJECT_NAME metadata function and a new OBJECT_SCHEMA_NAME metadata function
You may be aware OBJECT_NAME function can be use to return the database object name, I think since SQL 2000 when system functions are used the parameter of a system function is optional, the current database, host computer, server user, or database user is assumed. Also these system functions can be used in the select list, in the WHERE clause, and anywhere an expression is allowed.
If you haven't observed there is a new system function introduced since SP2 release whihc is OBJECT_SCHEMA_NAME that returns the database schema name for schema-scoped objects. And with this function the user (privileged) can only view the metadata of securables that the user owns or on which the user has been granted permission.
To return 3 part object name you could run:
SELECT QUOTENAME(DB_NAME(database_id))
+ N'.'
+ QUOTENAME(OBJECT_SCHEMA_NAME(object_id, database_id))
+ N'.'
+ QUOTENAME(OBJECT_NAME(object_id, database_id))
, *
FROM sys.dm_db_index_operational_stats(null, null, null, null);
GO
Also Umachander has explained more lot about these 2 system functions in here.
**__________________________________**
SQL Server MVP, Sr. DBA & industry expert.
-
Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it. It is also a power and you will gain by sharing it.