Jim Metcalf
asked on
Query not working as expected
I have a query that is supposed to return table name and last time it was touched and display the tablename and last update
for some reason under table name... it is returning null as its value
can someone correct the query please
SELECT OBJECT_NAME(OBJECT_ID) AS TableName, last_user_update
FROM sys.dm_db_index_usage_stat s
WHERE database_id = DB_ID( 'DATBASENAME')
AND last_user_update >= '2015-04-13 13:07:00'
--AND OBJECT_ID=OBJECT_ID('test' )
for some reason under table name... it is returning null as its value
can someone correct the query please
SELECT OBJECT_NAME(OBJECT_ID) AS TableName, last_user_update
FROM sys.dm_db_index_usage_stat
WHERE database_id = DB_ID( 'DATBASENAME')
AND last_user_update >= '2015-04-13 13:07:00'
--AND OBJECT_ID=OBJECT_ID('test'
SELECT OBJECT_NAME(OBJECT_ID) AS TableName, last_user_update
FROM sys.dm_db_index_usage_stat s
GROUP BY OBJECT_NAME(OBJECT_ID),las t_user_upd ate
ORDER BY last_user_update DESC
FROM sys.dm_db_index_usage_stat
GROUP BY OBJECT_NAME(OBJECT_ID),las
ORDER BY last_user_update DESC
ASKER
that was just an example of a database name... not needed to be spelled correctly
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DB_ID( 'DATBASENAME')
should be
DB_ID( 'DATABASENAME')