Posts

Showing posts from January, 2020

Msg 35295, Level 16, State 1, Line 5

Image
I got the below error in the SECONDARY replica transaction log backup jobs.  To resolve this issue i have removed respective database from the availability group of PRIMARY REPLICA database, if you do this automatically in the SECONDARY replica the database goes into RESTORING mode, then you can even delete this database from the secondary replica and go to PRIMARY replica and start database adding again. Then it will again to add to availability databases of PRIMARY and secondary.

DBCC INTEGRITY CHECK ERROR:Msg 8948, Sev 16, State 6, Line 1 : Database error: Page (1:36729) is marked with the wrong type in PFS page (1:32352). PFS status 0x40 expected 0x60. [SQLSTATE 42000]

Image
I got the below when on one of the Always on Databases while we are running DBCC INTEGRITY CHECK job. We need to bring the database to single user mode and need to execute REPAIR_ALLOW_DATA_LOSS. However this is not going to delete any data. ( https://www.sqlskills.com/blogs/paul/pfs-corruption-after-upgrading-from-sql-server-2014/ )

Getting SQL Server Agent Job status through Powershell

cls #Import sql serer module Import-Module sqlps -DisableNameChecking #Provide instance name $ServerNames = "SQLServerNamedInstanceName" $Server = New-Object ` -TypeName Microsoft.SQLServer.Management.Smo.Server ` -ArgumentList $ServerNames $Jobs = $Server . JobServer . Jobs $Jobs | Select-Object LastRunOutcome , OriginatingServer , Name , OwnerLoginName , LastRunDate , CurrentRunStatus , NextRunDate | Format-Table   -----On multiple instances. cls #Import sql serer module Import-Module sqlps -DisableNameChecking #Provide instance name $ServerNames = @( "Server1" , "Server2" , "Server3" ) $ServerNames | ForEach-Object { $ComputerName = $_ $Server = New-Object ` -TypeName Microsoft.SQLServer.Management.Smo.Server ` -ArgumentList $ComputerName $Jobs = $Server . JobServer . Jobs $Jobs | Select-Object LastRunOutcome , OriginatingServer , Name , OwnerLoginName , LastRunDate , CurrentRun