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_stats
WHERE database_id = DB_ID( 'DATBASENAME')
AND last_user_update >= '2015-04-13 13:07:00'
--AND OBJECT_ID=OBJECT_ID('test')
jamesmetcalf74Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark ElySenior Coldfusion DeveloperCommented:
You misspelled Database

DB_ID( 'DATBASENAME')  

should be

DB_ID( 'DATABASENAME')
0
Mark ElySenior Coldfusion DeveloperCommented:
SELECT OBJECT_NAME(OBJECT_ID) AS TableName, last_user_update
FROM sys.dm_db_index_usage_stats
GROUP BY OBJECT_NAME(OBJECT_ID),last_user_update
ORDER BY last_user_update DESC
0
jamesmetcalf74Author Commented:
that was just an example of a database name... not needed to be spelled correctly
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mark ElySenior Coldfusion DeveloperCommented:
SELECT DISTINCT(OBJECT_NAME(OBJECT_ID)) AS TableName, last_user_update
FROM sys.dm_db_index_usage_stats
WHERE OBJECT_NAME(OBJECT_ID) IS NOT NULL
ORDER BY last_user_update DESC
0
Mark ElySenior Coldfusion DeveloperCommented:
Note: the OBJECT_ID is database specific. If you pass in a three-part name, then it will resolve in any database.  If you pass in one part name then it tries to resolve in the current database, If not found, you will get NULL


https://msdn.microsoft.com/en-us/library/ms190328.aspx
0
Mark ElySenior Coldfusion DeveloperCommented:
James, if your goal is to monitor any changes that are made to any tables then you should read this article:

http://www.codeproject.com/Articles/338183/SQL-Server-Change-Tracking-on-Table-Without-Trigge
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott PletcherSenior DBACommented:
USE DATABASENAME
SELECT OBJECT_NAME(OBJECT_ID) AS TableName, MAX(last_user_update) AS last_user_update
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID()
AND last_user_update >= '20150413 13:07:00'
GROUP BY OBJECT_NAME(OBJECT_ID)
ORDER BY OBJECT_NAME(OBJECT_ID)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.