SQL Queries

Snapshot Isolation, Tranzakt

                            
                                SELECT 'ALTER DATABASE ['+name+'] SET ALLOW_SNAPSHOT_ISOLATION ON  
ALTER DATABASE ['+name+'] SET READ_COMMITTED_SNAPSHOT ON' 
FROM master.dbo.sysdatabases WHERE name NOT IN('master','tempdb','model','msdb')                            
                        

SUSPECT, EMERGENCY

Danger/ Backup database before
                            
                                EXEC sp_resetstatus [YourDatabase];
ALTER DATABASE [YourDatabase] SET EMERGENCY
DBCC checkdb([YourDatabase])
ALTER DATABASE [YourDatabase] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ([YourDatabase], REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE [YourDatabase] SET MULTI_USER                            
                        
                            
                                SELECT TOP 10 schema_name(tab.schema_id) + '.' + tab.name AS [table], 
CAST(SUM(spc.used_pages * 8)/1024.00 AS numeric(36, 2)) AS used_mb,
CAST(SUM(spc.total_pages * 8)/1024.00 AS numeric(36, 2)) AS allocated_mb
FROM sys.tables tab
JOIN sys.indexes ind ON tab.object_id = ind.object_id
JOIN sys.partitions part ON ind.object_id = part.object_id AND ind.index_id = part.index_id
JOIN sys.allocation_units spc ON part.partition_id = spc.container_id
GROUP BY schema_name(tab.schema_id) + '.' + tab.name
ORDER BY SUM(spc.used_pages) DESC;                            
                        

Command Prompt/PowerShell Commands

PowerShell ENABLE Fina LOG

                            
                                New-EventLog -Logname "Application" -Source "FINA Log (Program)"
New-EventLog -Logname "Application" -Source "FINA Log (SQL)"
Write-EventLog -Logname "Application" -Source "FINA Log (Program)" -EntryType Error -Message "ProgramLog Demo Message" -EventId 1000
Write-EventLog -Logname "Application" -Source "FINA Log (SQL)" -EntryType Error -Message "SQLLog Demo Message" -EventId 2000                            
                        

PowerShell Fix Win10-11

                            
                                sfc /scannow; DISM /Online /Cleanup-Image /CheckHealth; DISM /Online /Cleanup-Image /ScanHealth; DISM /Online /Cleanup-Image /RestoreHealth /Source:https://msft.crl.microsoft.com/picross/2024/01/windows10/20240101/windows10.cab                            
                        

Run Commands

NT Service\MSSQL$FINA 
NT Service\SQLAgent$FINA 
Inetmgr
SSMS