Author: Jugal Shah

  • Stripping SQL Server Database Backup to Multiple Files

    Stripping Database backup to multiple files and on different drives will make the backup speed faster and will reduce the backup duration.

    Check the below sample script for the backup and restore. You can perform the same task using SSMS GUI as well.
    Backup Script

    BACKUP DATABASE [SQLDBPool] TO  
    DISK = N'C:\JSpace\Backup\SQLDBPool1.bak',  
    DISK = N'C:\JSpace\Backup\SQLDBPool2.bak',  
    DISK = N'C:\JSpace\Backup\SQLDBPool3.bak'
    WITH NOFORMAT, 
    NOINIT,  
    NAME = N'SQLDBPool-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
    GO
    

    Restore Script

    RESTORE DATABASE [SQLDBPool] FROM  
    DISK = N'C:\JSpace\Backup\SQLDBPool1.bak',  
    DISK = N'C:\JSpace\Backup\SQLDBPool2.bak',  
    DISK = N'C:\JSpace\Backup\SQLDBPool3.bak'
    WITH  FILE = 1,  NOUNLOAD,  STATS = 10,replace
    GO
    
  • Script to find out the traces running on SQL Server instance

    You can execute the below script on SQL Server instance to find out the traces, trace type, trace file path and trace status.

    select
          TraceType =
           case trace.is_default
                when 1 THEN 'Default/System Trace'
                when 0 THEN 'User Trace'
           end,
          Trace_Status =
          case trace.status
                when 1 THEN 'Running'
                when 0 THEN 'Stopped'
          end,
           ssion.session_id as SessionID,
           [loginName] = coalesce(ssion.login_name,ssion.login_name,'Reader SPID Not mentioned'),
           [Trace_File_Path] = coalesce(trace.[Path],trace.[Path],'OLEDB Client Trace')
          from sys.traces trace
                left join sys.dm_exec_sessions ssion on trace.reader_spid = ssion.session_id
    
  • Script to get the SQL Server Installation Date and Authentication Mode

    Recently I got a request where I have to check the SQL Server installation date and SQL Server authentication mode. I have write the below script and execute it against all the servers registered in CMS.

    Here is the script

    select createdate as InstallationDate ,
    CASE SERVERPROPERTY('IsIntegratedSecurityOnly')   
    WHEN 1 THEN 'Windows Authentication'   
    WHEN 0 THEN 'Windows and SQL Server Authentication'   
    END as [AuthenticationMode],
    SERVERPROPERTY('servername') as svrName 
    from master..syslogins where name like 'NT AUTHORITY\SYSTEM'