July 25, 2011 at 12:51 pm
I'm looking to return the table name for an object_id from the sys_dm_db_index_physical_stats.
How would I go about that?
July 25, 2011 at 1:06 pm
the object_name() function has a second parameter to pass the database id; i think it got added ina Sp of 2005, and 2008 and above:
select
db_name(database_id) As DBName,
object_name(object_id,database_id) As ObjectName,
MyAlias.* from sys.dm_db_index_physical_stats(NULL,NULL,NULL,NULL,NULL) MyAlias
Lowell
July 25, 2011 at 1:09 pm
Try this
SELECT DB_NAME(PS.database_id) AS DBName,OBJECT_NAME(PS.object_id) AS TableName,PS.*
FROM sys.dm_db_index_physical_stats
(DB_ID(), null, NULL, NULL , 'DETAILED') PS
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
July 25, 2011 at 1:09 pm
Lowell (7/25/2011)
the object_name() function has a second parameter to pass the database id; i think it got added ina Sp of 2005, and 2008 and above:
select
db_name(database_id) As DBName,
object_name(object_id,database_id) As ObjectName,
MyAlias.* from sys.dm_db_index_physical_stats(NULL,NULL,NULL,NULL,NULL) MyAlias
Curses - you beat me
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
July 25, 2011 at 1:24 pm
Thanks guys ...
July 25, 2011 at 1:25 pm
NP
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply