VERIFIED SOLUTION i

How to restore a database in SQL Server for Confirm

The process of restoring a Database Backup file from the Local Machine and use of some SQL Scripts for Confirm is as follows.
1.       Very 1st Install SQL SERVER  2008 (for installation process please refer “SQL_SERVER_2008.docx”)
2.       Go to Start > All Programs > Microsoft Sql Server 2008 > SQL Server Management Studio
a.       Server Type : Database Engine
b.      Server Name : (Your Machine name)
c.       Authentication : SQL server Authentication

Give Login & password and connect.
  1. Go to View Menu & open  “Object Explorer”
  2. Right Click on ‘Databases’ Node and select ‘Restore Database’
  3. Select ‘From device’
  4. Click button to display ‘Specify Backup’ Dialog.
  5. Click ‘Add’ to browse the .bak file from the directory and click OK.
  6. (.bak files are database backups we can restore the Database backup using SQL Server Management Studio.)
  7. Select “To Database : (Give the name of Database)”
  8. Tick the “Restore” checkbox.

1.  Then open a new query and run the following command so as to create logins:
2.  Select Database :             Authority
3.  Login Names à               1.           Shared
2.    sbs
3.    highways
4.    grounds
5.    property
6.    tree
 
i)     DECLARE
            @Database varchar(50),
            @Password varchar(50),
            @LoginName varchar(50),
            @sql varchar(200)
 
SET @LoginName = 'shared' -- put login name.
SET @Password = 'shared' -- put password here.
 
SET @sql='CREATE LOGIN '+@LoginName +' WITH PASSWORD ='''+@Password +''''+ ',
DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF'
PRINT @sql
EXEC (@sql)
 
 
 
ii)exec sp_changedbowner 'shared';
            exec sp_change_users_login 'update_one', 'sbs', 'sbs';
            exec sp_change_users_login 'update_one', 'highways', 'highways';
            exec sp_change_users_login 'update_one', 'grounds', 'grounds';
            exec sp_change_users_login 'update_one', 'property', 'property';
            exec sp_change_users_login 'update_one', 'tree', 'tree';
 
iii)    Update user_login set password='' where login_name='sbs'
 
iv)Select * from user_login
 

 
Note : The above steps for “Authority” Database. Repeat the steps for “Utility” database.


 
UPDATED:  August 23, 2017