The procedure bellow get the data and log size of all databases in current instance.
CREATE PROCEDURE dbo.uspDatabaseSize
@tbl table (Database_Id int, DataUsedMB Float)
insert into @tbl
'select db_id(''?'') , (SUM(ps.reserved_page_count)*8)/1024 from ?.sys.dm_db_partition_stats ps';
DB_ID(d.instance_name)… Read more
Hi people, following a script that deletes all tables in a database. Enjoy.
SET NOCOUNT ON;
DECLARE @Tabela TABLE
( Seq INT,
DECLARE @Loop INT, @Qt INT;
-- While there ForeignKey exclude objects that are not referenced recursively
WHILE (SELECT COUNT(*) FROM… Read more
The Profiler is a powerful tool available to the dba, but it can also be very useful for system developers. Of course I'm thinking about development environments (production never). Thus, the profiler can help developers monitor the queries and stored procedures developed in the applications.
Follow the instruction to… Read more
Occasionally I need to see what the date of last restart of SQL Server. The old method isto check the creation date of tempdb database. However, in SQL 2008 we have a DMV that can be used for this purpose: sys.dm_os_sys_info. Here's how:
1) Searching creation of tempdb
SELECT… Read more
Sometimes when we need to do some maintenance on a SQL server, you need to verify which users are connected or which databases are being used. A quick and easy wayto check the server utilization is simply to identify which databases are being accessedat that time. Thus, I present two… Read more
The script below is a simple and quick way to find out the last backup performed successfully to the databases an SQL server.
,REVERSE (SUBSTRING (REVERSE (CONVERT… Read more