For frequent migration to different environment we have to provide scripts for any database changes, most of the time developer forget to send few of the scripts which causes error in the other environments.
I am using SQL server 2005.
I was looking for any sql query which can list the create date and modify date of table, stored procedure, views etc in a database.
I google and found the below query but I get the below error message:
" Invalid object name 'sys.objects'."
SELECT name
FROM sys.objects
WHERE type = 'P'
AND DATEDIFF(D,modify_date, GETDATE()) < 7
Note: I do not have access to Master database.I have also tired the below query:
SELECT name
FROM sysobjects
WHERE type = 'P'
AND DATEDIFF(D,modify_date, GETDATE()) < 7but then I get this error message : Invalid column name 'modify_date'.
Please suggest.
Thanks.
![]() |
0 |
![]() |
I run the first query in my database and got the results OK. Are you sure your SQL Server uses default non-case sensitive collation?
Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
![]() |
0 |
![]() |
gridview:
SELECT name
FROM sys.objects
WHERE type = 'P'
AND DATEDIFF(D,modify_date, GETDATE()) < 7
Note: I do not have access to Master database.All the "sys" view have been introduced in 2005 only. Whenever a new database gets created, all the system objects ( tables, views, procedures ) get created for that. So, if you access any "sys" object from within any database, that means you are accessing it from that database only ( database specific ). So, you do not necessarily want access to the master database.
gridview:
SELECT name
FROM sysobjects
WHERE type = 'P'
AND DATEDIFF(D,modify_date, GETDATE()) < 7but then I get this error message : Invalid column name 'modify_date'.
The "modify_date" column is a newer entry in the "sys" object specific views. So, you will not find it in the "sysobjects". This way the error is quite obvious.
Can you run the below query and post the results here ?
select @@version
Thanks,
Dhimant Trivedi
"When the going gets tough, tough gets going."
"Mark as Answer" the post(s) which helped you solve the problem
![]() |
0 |
![]() |
Dhimant,
thanks for your reply, here is the result i get after running @@version:
Microsoft SQL Server 2000 - 8.00.2273 (Intel X86) Mar 7 2008 22:19:58 Copyright (c) 1988-2003 Microsoft Corporation Enterprise Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
so i am not using SQL server 2005, Is there any equivalent query in SQL Server 2000 which can give 'last modified date' ?
dhimant:
gridview:
SELECT name
FROM sys.objects
WHERE type = 'P'
AND DATEDIFF(D,modify_date, GETDATE()) < 7
Note: I do not have access to Master database.All the "sys" view have been introduced in 2005 only. Whenever a new database gets created, all the system objects ( tables, views, procedures ) get created for that. So, if you access any "sys" object from within any database, that means you are accessing it from that database only ( database specific ). So, you do not necessarily want access to the master database.
gridview:
SELECT name
FROM sysobjects
WHERE type = 'P'
AND DATEDIFF(D,modify_date, GETDATE()) < 7but then I get this error message : Invalid column name 'modify_date'.
The "modify_date" column is a newer entry in the "sys" object specific views. So, you will not find it in the "sysobjects". This way the error is quite obvious.
Can you run the below query and post the results here ?
select @@version
![]() |
0 |
![]() |
By quick search I found this http://forums.asp.net/p/948921/1152484.aspx#1152484 so looks like you're out of luck.
Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
![]() |
0 |
![]() |
gridview:
thanks for your reply, here is the result i get after running @@version:
Microsoft SQL Server 2000 - 8.00.2273 (Intel X86) Mar 7 2008 22:19:58 Copyright (c) 1988-2003 Microsoft Corporation Enterprise Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
so i am not using SQL server 2005, Is there any equivalent query in SQL Server 2000 which can give 'last modified date' ?
AFAIK, I'm afraid no, there is no way to find that value. I personally faced similar situation when I was using 2000 and couldn't manage to find the last modified date of crucial objects.
Thanks,
Dhimant Trivedi
"When the going gets tough, tough gets going."
"Mark as Answer" the post(s) which helped you solve the problem
![]() |
0 |
![]() |