473,503 Members | 12,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

removing unused objects - SQL Server 2000 or 2005

Sometimes at the end of a project you'll end up with unused Tables,
Stored Procs, Functions, and Views.
Since there is not something like a 'SELECT' trigger ... what is the
best way for telling what is not being used by your solution? To turn
on some kind of tracing?

Any ideas?

Thanks,
Kelly Greer
ke*********@nospam.com
change nospam to yahoo

Jan 22 '08 #1
4 5676
Copy -Paste from Tony articles

In SQL 2005 there is, sort of. This is query lists the last execution
time for all SQL modules in a database:

SELECT object_name(m.object_id), MAX(qs.last_execution_time)
FROM sys.sql_modules m
LEFT JOIN (sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text (qs.sql_handle) st)
ON m.object_id = st.objectid
AND st.dbid = db_id()
GROUP BY object_name(m.object_id)

But there are tons of caveats. The starting point of this query is
the dynamic management view dm_exec_query_stats, and the contents is
per *query plan*. If a stored procedure contains several queries,
there are more than one entry for the procedure in dm_exec_query_stats.

"kellygreer1" <ke*********@yahoo.comwrote in message
news:8f**********************************@v46g2000 hsv.googlegroups.com...
Sometimes at the end of a project you'll end up with unused Tables,
Stored Procs, Functions, and Views.
Since there is not something like a 'SELECT' trigger ... what is the
best way for telling what is not being used by your solution? To turn
on some kind of tracing?

Any ideas?

Thanks,
Kelly Greer
ke*********@nospam.com
change nospam to yahoo

Jan 22 '08 #2
Uri Dimant (ur**@iscar.co.il) writes:
Copy -Paste from Tony articles

In SQL 2005 there is, sort of. This is query lists the last execution
time for all SQL modules in a database:

SELECT object_name(m.object_id), MAX(qs.last_execution_time)
FROM sys.sql_modules m
LEFT JOIN (sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text (qs.sql_handle) st)
ON m.object_id = st.objectid
AND st.dbid = db_id()
GROUP BY object_name(m.object_id)

But there are tons of caveats. The starting point of this query is
the dynamic management view dm_exec_query_stats, and the contents is
per *query plan*. If a stored procedure contains several queries,
there are more than one entry for the procedure in dm_exec_query_stats.
And very importantly: it only lists what's in the cache. A procedure could
fall out of the cahce for several reasons. For instance, adding an index
on a table, flushes all plans related to that table. And a server restart
empites the cache entirely.

I would be very careful to use information of that kind to draw
conclusion of whether an object is in use.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jan 22 '08 #3
On Jan 21, 6:36 pm, kellygreer1 <kellygre...@yahoo.comwrote:
Sometimes at the end of a project you'll end up with unused Tables,
Stored Procs, Functions, and Views.
Since there is not something like a 'SELECT' trigger ... what is the
best way for telling what is not being used by your solution? To turn
on some kind of tracing?

Any ideas?

Thanks,
Kelly Greer
kellygre...@nospam.com
change nospam to yahoo
have you checked out SQL Dependency Tracker?
Jan 22 '08 #4
On Jan 22, 5:28 pm, Alex Kuznetsov <alk...@gmail.comwrote:
On Jan 21, 6:36 pm,kellygreer1<kellygre...@yahoo.comwrote:
Sometimes at the end of a project you'll end up with unused Tables,
Stored Procs, Functions, and Views.
Since there is not something like a 'SELECT' trigger ... what is the
best way for telling what is not being used by your solution? To turn
on some kind of tracing?
Any ideas?
Thanks,
Kelly Greer
kellygre...@nospam.com
change nospam to yahoo

have you checked out SQL Dependency Tracker?
Thanks for the ideas. I'm going to try this SQL Dependency Tracker
too.
See they have a trial on their site.

kellygreer1
Jan 23 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2793
by: Chris Halcrow | last post by:
Hi I've spent ALL DAY trying to re-install SQL Server 2000 on Windows XP. I continually get the error 'cannot configure server' just at the end of the installation. I've tried the following: ...
3
2217
by: datapro01 | last post by:
I am a DB2 DBA that has been asked to become familiar enough with SQL Server in order to become actively involved in its installation, implementation, and to review database backup/recovery...
2
1448
by: mal hit | last post by:
I would like to know if it's possible to embed a SQL Server 2000/2005 DB within a desktop application so that the end users cannot view the DB. Also, this will prevent them from copying the...
0
1973
by: dunleav1 | last post by:
Does enabling/disabling Data Execution Prevention (DEP) have a performance impact on SQL 2000 or SQL 2005?
4
3743
by: David | last post by:
Hi all, I just asked some people to help me out and phone microsoft with the following information, kindly they refused unless we setup a support contract with them first, for pre-sales...
0
1049
by: samindra | last post by:
I need to Add & update 100 plus users info daily basis. Right now I am doing one at a time through the vendors GUI interface. I need to do this process with bulk additions & bulk updates. My db...
0
1317
by: =?Utf-8?B?RENvdW50MTc=?= | last post by:
I need to create a windows application in which I can programmatically create local cubes from SQL Server 2005 databases using C#. I was able to do this in SQL Server 2000, but I cannot get the...
4
4120
by: Feris T | last post by:
Hi, Is there any development library exist in the market for SQL Server 2000/2005 transaction log reader ? I need to use it for Capture Data Change (CDC). Preferably Java. Regards, Feris
2
2520
by: Yemata Abebe | last post by:
What is the maximum number of records SQL Server 2000, 2005 and Oracle 11g can handle
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7296
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.