Posts

Showing posts from December, 2017

Some useful windows command for SQL DBAs

Finding Uptime systeminfo | find /i "Boot Time" System Boot Time:          14/12/2017, 7:48:04 AM Cluster Command cluster resource /status cluster node /status cluster group /status Finding Processor Info for the total number of cores echo %NUMBER_OF_PROCESSORS% Go to RUN --> msinfo32 Finding Memory Info Windows Cmd: wmic ComputerSystem get TotalPhysicalMemory && wmic OS get FreePhysicalMemory,TotalVirtualMemorySize,FreeVirtualMemory Results will be in bytes Powershell Cmd: (Get-WMIObject Win32_PhysicalMemory |  Measure-Object Capacity -Sum).sum/1GB For Remoting: For ($x in serverlist.txt) { $colItems = get-wmiobject -class "Win32_ComputerSystem" -computername $x foreach ($objItem in $colItems){ $displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0) write-host "Total Physical Memory: " $displayGB "GB" write-host "Model: " $objItem.Model } $colItems = get-wmiobje

Joining DB to AOAG

Steps: 1. Disable backup jobs 2. Go to Primary node. Take a Full and TLog backup. Copy it over to the secondary. 3. Restore the full with Recovery option in secondary. Then change the owner to 'SA'. Restore the DB again. It will not change the owner any more. Another way to do it - login as 'SA' in the secondary node and then restore it. 4. Restore the TLog after that in No Recovery Mode. 5. Go to the Primary again. Right click on the AOAG name and select add databases in the AOAG. 6. In the AOAG config GUI select join only and proceed. 7. The new databases should be joined now. Things to remember: 1. Check the owner in both nodes. it should be 'SA'. If not it needs to be changed. Another approach is to restore with command Execute as login = 'sa'; GO USE master; GO -- First determine the number and names of the files in the backup. -- AdventureWorks2012_Backup is the name of the backup device. RESTORE FILELISTONLY FROM Ad