Tuesday, July 28, 2015

Could not redo log record - DB is SUSPECT Mode

We recently faced this issue after the maintenance window. The user database went to suspect mode and it was unable to bring online due to below error.
This case we rebuilt the logfile, to bring the DB online.

ERROR
Could not redo log record (1327929:29486:115), for transaction ID (1:1223281085), on page (1:1333024), database 'TestDB2 ' (database ID 8). Page: LSN = (1327558:113348:307), type = 2. Log: OpCode = 5, context 29, PrevPageLSN: (1327929:29486:18). Restore from a backup of the database, or repair the database.

Msg 3313, Level 21, State 2, Line 1

This case has only below options:

1. Restore the DB from the backup strategy.
2. Try DBCC REPAIR with REPAIR_FAST | REPAIR_REBUILD (No Data Loss)
3.  Final is REPAIR_ALLOW_DATA_LOSS

Alternate Solution:
===================

ALTER DATABASE TestDB2 REBUILD LOG ON (NAME=TestDB2_Log, FILENAME='D:\SQLLog\TestDB2_Log.ldf')
dbcc checkdb (testdb2)
ALTER DATABASE testdb2 SET MULTI_USER

Note: This approach might lead to data loss. Make sure we have enough backups in place.

Monday, July 27, 2015

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 18452)

Solution :

1. Go to  C:\Windows\System32\drivers\etc
2. Open HOSTS File in notepad (Run as Admin)
3. Add below lines:

127.0.0.1 localhost
127.0.0.1 mycomputername -- this will be computer name


4. Save and close the notepad.
5. Connect SQL Server


Source:

http://blog.sqlauthority.com/2012/09/06/sql-server-fix-error-cannot-connect-to-login-failed-the-login-is-from-an-untrusted-domain-and-cannot-be-used-with-windows-authentication-microsoft-sql-server-error-18452/

 

Sunday, June 28, 2015

How to find PID

Here in the TSQL Script to find PID Key:

USE master
GO
EXEC xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Microsoft
SQL Server\80\Registration'
,'CD_KEY'
GO


References:

http://blog.sqlauthority.com/2007/02/28/sql-server-t-sql-script-to-find-the-cd-key-from-registry/

https://gallery.technet.microsoft.com/scriptcenter/Get-SQL-Server-Product-4b5bf4f8