January 17, 2019
June 13, 2018
How to Find Free Log Space in SQL Server?
This post will show you how to monitor free log space in SQL Server.
Method 1: Using SQLPERF
DBCC SQLPERF ('LOGSPACE')
GO
Method 2: sys.dm_db_log_space_usage
SELECT total_log_size_in_bytes*1.0/1024/1024 total_log_size_in_MB,
used_log_space_in_bytes*1.0/1024/1024 used_log_space_in_MB,
(total_log_size_in_bytes - used_log_space_in_bytes)*1.0/1024/1024
AS free_log_space_in_MB
FROM sys.dm_db_log_space_usage;
Method 1: Using SQLPERF
DBCC SQLPERF ('LOGSPACE')
GO
Method 2: sys.dm_db_log_space_usage
SELECT total_log_size_in_bytes*1.0/1024/1024 total_log_size_in_MB,
used_log_space_in_bytes*1.0/1024/1024 used_log_space_in_MB,
(total_log_size_in_bytes - used_log_space_in_bytes)*1.0/1024/1024
AS free_log_space_in_MB
FROM sys.dm_db_log_space_usage;
December 6, 2017
How to Validate Email Address in SQL Server?
How to Validate Email Address in SQL Server-Let us create a column called Email Address in the table named Contacts.
Once we create the table, we will insert few valid and invalid email
address in it.
October 3, 2017
Different Methods to Know COMPATIBILITY LEVEL of a Database
There are many methods to know the compatibility levels of a database.
1) Use system stored procedure sp_helpdb
EXEC sp_helpdb TEST
1) Use system stored procedure sp_helpdb
EXEC sp_helpdb TEST
How to Change Compatibility of Database
There are two different ways how we can change the compatibility of database to SQL Server.
1) Using Management Studio
For this method first to go database and right click over it. Now select properties.
2) Using T-SQL Script.
You can execute following script and change the compatibility settings to 120.
USE [master] GO
ALTER DATABASE [TEST] SET COMPATIBILITY_LEVEL = 120
GO
1) Using Management Studio
For this method first to go database and right click over it. Now select properties.
2) Using T-SQL Script.
You can execute following script and change the compatibility settings to 120.
USE [master] GO
ALTER DATABASE [TEST] SET COMPATIBILITY_LEVEL = 120
GO
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
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
Subscribe to:
Posts (Atom)