top of page

Search
Find SQL Server Version
-- SQL and OS Version information for current instance SELECT @@VERSION AS [SQL Server and OS Version Info];

Kunal Ranpura
Jul 29, 20191 min read
4 views
0 comments
Script to restore multiple database backups
The following script will generate output script with restore command to restore all log backup located at L:\Log_Backup\DB_Name\ exec...

Kunal Ranpura
Jul 29, 20192 min read
24 views
0 comments
Change DB_Owner to SA
/* The Code */ --If you want to get a list of current owners who aren't sa SELECT suser_sname(owner_sid) as DBOwner, Name as DBName FROM...

Kunal Ranpura
Jul 29, 20191 min read
4 views
0 comments
Script to find SQL Server Data and Log file Auto Growth Event
--Script to find autogrowth event from the default trace. DECLARE @filename NVARCHAR(1000); DECLARE @bc INT; DECLARE @ec INT; DECLARE...

Kunal Ranpura
Jul 29, 20191 min read
9 views
0 comments
Find Job History for all SQL Server Agent Jobs.
Use msdb go select distinct j.Name as "Job Name", --j.job_id, case j.enabled when 1 then 'Enable' when 0 then 'Disable' end as "Job...
Kunal Ranpura
Jul 29, 20191 min read
4 views
0 comments
Script to list table names short by total space used desc.
SELECT t.NAME AS TableName, s.Name AS SchemaName, p.rows AS RowCounts, SUM(a.total_pages) * 8 AS TotalSpaceKB, SUM(a.used_pages) * 8 AS...
Kunal Ranpura
Jul 29, 20191 min read
8 views
0 comments
Script to compare data between two tables
-- Show data in table dbtest02 that do not exists in dbtest01 select * from dbtest02.dbo.article except select * from dbtest01.dbo.article
Kunal Ranpura
Jul 28, 20191 min read
10 views
0 comments
bottom of page