November 21, 2016

Ms SQL Useful Stored Procedures

DBCC CHECKDB ('DB_Name')
DBCC CHECKALLOC ('DB_Name')
DBCC updateusage ('DB_Name')
DBCC CHECKIDENT ('dbo.tablename',reseed,0
- '0' by default,Seed Value Last Incremented value can be added

EXEC SP_help

EXEC SP_helptext

EXEC sp_renamedb 'oldname' , 'newname';

xp_fixeddrives  - To get HD available in the Server / Disk Space

To Get List of Jobs running in SQL Agent Job



How to find the SQL Agent Jobs  running in your DB Instance and its Steps, query used for the results

 SELECT J.NAME AS 'JOB NAME',
S.STEP_ID AS 'STEP',
S.STEP_NAME AS 'STEP NAME',
S.COMMAND AS 'QUERY',
DATABASE_NAME AS 'DATABASE'
FROM MSDB.DBO.SYSJOBS J
INNER JOIN MSDB.DBO.SYSJOBSTEPS S ON S.JOB_ID = J.JOB_ID
WHERE J.ENABLED = 1
ORDER BY J.NAME,S.STEP_ID