Skip to content

Check SQL Server Backups

SELECT CONVERT(CHAR(100), SERVERPROPERTY(‘Servername’)) AS Server, msdb.dbo.backupset.database_name, msdb.dbo.backupset.backup_start_date, msdb.dbo.backupset.backup_finish_date, msdb.dbo.backupset.expiration_date, CASE msdb..backupset.type WHEN ‘D’ THEN ‘Database’ WHEN ‘L’ THEN ‘Log’ WHEN ‘I’ THEN ‘Differential Database’ WHEN ‘F’ THEN ‘File or filegroup’ WHEN ‘G’ THEN ‘Differential file’… 

Oracle hash values for Passwords

set long 150 set linesize 150 set longchunksize 150 select ‘alter user ‘||username||’ identified by values ‘||REGEXP_SUBSTR(DBMS_METADATA.get_ddl (‘USER’,USERNAME), ”'[^”]+”’)||’;’ from dba_users

Powershell – Recursive Search for Strings in Files

To search for a string (grep) in files recursively with Powershell (example): gci -recurse -include *.sql|%{gc $_} | %{$_|select-string “dba”} To get the filename(s): gci -recurse -include *.txt|%{$Filename=$_;gc $_} | %{$res=$_|select-string “dba”;if ($res) {Write-Host “$Filename”}}

SQL Server – Display Running Tasks

Use this query in conjunction with sp_who to display running tasks and determine whether there are sessions blocking other sessions, and who is executing the query (sp_who) SELECT command, r.session_id, r.blocking_session_id, s.text, start_time, percent_complete, CAST(((DATEDIFF(s,start_time,GetDate()))/3600)…