I have the following query in my php script:
SELECT last_value FROM sys.identity_columns WHERE OBJECT_NAME(OBJECT_ID) = 'MYTABLE' AND last_value IS NOT NULL
This works great, it returns the last id from MYTABLE which is what I need.
But, as I'm going to have more than one database I should modify the query to select the database where MYTABLE is.
I'm doing:
SELECT last_value FROM sys.identity_columns WHERE OBJECT_NAME(OBJECT_ID) = 'mydatabase.dbo.MYTABLE' AND last_value IS NOT NULL
But this does not work, I get nothing in return.
Any ideas?
Thanks a lot!