select top 5 database_name,convert(varchar(20),backup_finish_date) as Date, (bac

kup_size/1024/1024) as Size from msdb..backupset where type='l'
order by backup_finish_date desc
--------------------------------------------------------------------------------------------------------------SELECT * FROM fn_trace_getinfo(default);-- to check the traces running on the in
--------------------------------------------------------------------------------------------------------------select compatibility_level from sys.databases where name in (select name from ma
ster..sysdatabases where name not in ('master','model','tempdb','msdb')) fin
d the compatibility level of user db..
----------------------------------------------------------------------------------------------------------------select name,recovery_model from sys.databases where name in (select name from m
aster..sysdatabases where name not in ('master','model','tempdb','msdb')) --to f
ind the recovery model of all the user db...
----------------------------------------------------------------------------------------------------------------select name, is_auto_close_on from sys.databases where name in (select name fro
m master..sysdatabases where name not in ('master','model','tempdb','msdb'))
--------------------------------------------------------------------------------------------------------------select name, is_auto_shirnk_on from sys.databases where name in (select name fr
om master..sysdatabases where name not in ('master','model','tempdb','msdb'))
---------------------------------------------------------------------------------------------------------------Find Long running queries in SQL2005
Select dmText.text as 'Executed Query',dmStats.last_execution_time as 'Last Exec
uted Time', dmstats.*
sys.dm_exec_query_stats as dmStats
Cross apply
sys.dm_exec_sql_text(dmStats.sql_handle) as dmText
Order By
total_elapsed_time desc,
dmStats.last_execution_time desc
---------------------------------------------------------------------------------------------------------------see the physical memory allocation
(Physical_memory_in_bytes/1024.0)/1024.0 AS Physical_memory_in_Mb
FROM sys.dm_os_sys_info
how much memory SQL Server has allocated through AWE.
SUM(awe_allocated_kb) / 1024 as [AWE allocated, Mb]
FROM sys.dm_os_memory_clerks
get the memory consumption by internal components of SQL Server 2005
SELECT TOP 10 type,
SUM(single_pages_kb) as [SPA Mem, Kb]
FROM sys.dm_os_memory_clerks

sysprocesses WHERE waittime > 10000 --The wait time is measured in milliseconds AND spid > 50 ----------------------------------------------------------------------------------------------------------------Find Objects in SQL Server ********************************************************* ** Find The Names And Types Of The T-SQL Objects ** Used In A Stored Procedure ** ** By: Dave Vroman *********************************************************/ DECLARE @ProcName VARCHAR(50) . getdate ( )) AS [WaitTime(s)] FROM master. waittime. waitresource FROM master..grantee_principal_id=b. datediff(s. last_batch.syslockinfo l WHERE req_spid = p.sys.server_principals b where a. 'user'. lastwaittype. ----------------------------------------------------------------------------------------------------------------fixed orphaned SQL Server users EXEC sp_change_users_login 'Report' EXEC sp_change_users_login 'Auto_Fix'.GROUP BY type ORDER BY SUM(single_pages_kb) DESC Finally. 'password' -----------------------------------------------------------------------------------------------------------------Identifying db locks performance monitor -> locks objects profiler might be caused by I/O bottleneck try to use index for update and delete SP_INDEXOPTION : page lock. row lock.* from -----------------------------------------------------------------------------------------------------------------how to check the user s server permission select %username% . getdate ()) > 30 ANd EXISTS (SELECT * FROM p WHERE open_tran > 0 AND spid > 50 AND datediff (s..principal_id and b. using dbcc memorystatus tion.etc use nolock for select (dirty read) sp_lock sp_who/sp_who2 --shwo long running process-SELECT spid.spid AND rsc_type <> 2) SELECT spid. loginame. ms s kb artiacle: can get the snapshot for the system memory alloca http://support. table lock . cmd. 'login'. last_batch.server_permissions a.. open_tran.. 'user' EXEC sp_change_users_login 'Auto_Fix'. status.

Name .ID --AND SO. SO.Name.depid FROM sysobjects so.Id = SC.Type FROM sysobjects SO (NOLOCK) INNER JOIN syscomments SC (NOLOCK) on SO. sysdepends sd WHERE so.Text LIKE '%ObjectsName%' --need to be replicated ORDER BY = @ProcName AND sd.V AND ) -------------------------------------------------SELECT Distinct SO. CASE WHEN xType = 'C' THEN 'CHECK Constraint' WHEN xType = 'D' THEN 'Default Or DEFAULT Constraint' WHEN xType = 'F' THEN 'FOREIGN KEY Constraint' WHEN xType = 'L' THEN 'Log' WHEN xType = 'FN' THEN 'Scalar Function' WHEN xType = 'IF' THEN 'Inlined Table-Function' WHEN xType = 'P' THEN 'Stored Procedure' WHEN xType = 'PK' THEN 'PRIMARY KEY Constraint (Type Is K)' WHEN xType = 'RF' THEN 'Replication Filter Stored Procedure' WHEN xType = 'S' THEN 'System Table' WHEN xType = 'TF' THEN 'Table Function' WHEN xType = 'TR' THEN 'Trigger' WHEN xType = 'U' THEN 'User Table' WHEN xType = 'UQ' THEN 'UNIQUE Constraint (Type Is K)' WHEN xType = 'V' THEN 'View' WHEN xType = 'X' THEN 'Extended Stored Procedure' ELSE xType END AS xType FROM sysobjects WHERE id IN (SELECT = so.Type = 'P' --U.P.SET @ProcName = 'MyTestProc' SELECT [Name].

Sign up to vote on this title
UsefulNot useful