ORPHAN USERS FIND AND FIX SCRIPT in SQL Server

Orphan Users find and fix: after the migration need to find and if is there any orphan users need to fix

EXEC sp_change_users_login 'Report'

--Use below code to fix the Orphan User issue

DECLARE @username varchar(25)
DECLARE fixusers CURSOR
FOR
SELECT UserName = name FROM sysusers
WHERE issqluser = 1 and (sid is not null and sid <> 0x0)
and suser_sname(sid) is null
ORDER BY name
OPEN fixusers
FETCH NEXT FROM fixusers
INTO @username
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC sp_change_users_login 'update_one', @username, @username
FETCH NEXT FROM fixusers
INTO @username
END
CLOSE fixusers
DEALLOCATE fixusers

Unable to Restore the backup files in SQL Server

1. Check whether the Backup is valid or not Restore verifyonly from disk = ‘Backup path’

2. We will check the Base Backup is restored first or not

3. Check the LSN sequence 4. Check user has required permissions

5. Check the disk space

6. We will check basing upon the error message.

Services Failed to start in windows

1. SCM – start instance (run: sqlservermanager.msc)

2. OS services (run: services.msc)

3. SAC – Surface Area Configuration (2005)

4. On the command line: Run – net start service name Find the service name in services.msc

5. Using object explorer (Right click on the instance and try to start)

6. Startup parameters have incorrect file path locations. Right click the instance -> Properties -> General Tab -> startup parameters

7. Need to check whether Services are disabled or not Services.msc

8. We will check basing upon the error message