Latest Event Updates

Recover a Deleted Stored Procedure

Posted on Updated on

To recover a deleted object, the SQL Service MUST NOT be restarted. If the SQL Service has been restarted then you won’t be able to find your deleted Stored Procedure.

SELECT A.objtype, B.text, C.query_plan
FROM sys.dm_exec_cached_plans A
CROSS APPLY sys.dm_exec_sql_text ( A.plan_handle ) B
CROSS APPLY sys.dm_exec_query_plan ( A.plan_handle ) C
WHERE B.text LIKE ‘%Alter%’

Advertisements

Check if TABLE exist

Posted on Updated on

Check if the table exists before dropping the table.

IF OBJECT_ID(‘dbo.Customer‘) IS NOT NULL
     DROP TABLE dbo.Customer
ELSE
     PRINTTable already exist

Find SQL Version installed

Posted on Updated on

SQL Versions: 2005, 2008, 2008 R2, 2012, 2014

If you need to see the specific version of SQL you’re running.

SELECT @@VERSIONN

Find current Service Pack installed

Posted on

SQL Versions: 2005, 2008, 2008 R2, 2012, 2014

If you need to see the specific version of SQL Service Pack installed. This SP is not the same as the Windows OS SP.

SELECT SERVERPROPERTY(‘ProductLevel‘)