Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Restore DB from Disk File script

By David A. Long,

This script was designed to restore a backup of a production database from disk file, handle multiple DB files, move the files to new location, with new database name that is customized for the date of the backup, create any missing logins, and fix any user accounts that are orphaned by differing SIDs from the other server.
It has one area that is custom for my use, we create two user accounts and related roles, one is to allow 3rd party access (this reads minimal rights), and the other for internal application access (this reads full rights). These accounts are assigned to two roles. Which role defines how I create default passwords for new logins on my development server. You may notice that I like to make the login's default database tempdb, that way each time I restart the server, any objects created by the 3rd party login will be dumped when the tempdb is created.
Hey, works for me, especially for novice users.

Total article views: 999 | Views in the last 30 days: 2
 
Related Articles
SCRIPT

Delete All Database User Accounts for a Given Server Login

Easily and quickly delete all database accounts even if they don't have the same name as server logi...

FORUM

Where to create the login and user account

Where to create the login and user account

FORUM

User logins versus service account

User logins versus service account

FORUM

how to create user group logins in SQL server 2005

how to create user group logins in SQL server 2005

BLOG

SQL Server 2014 Best Practice: Set built-in Sysadmin(sa) account as an default owner of all databases on SQL Server instance

As we know, when we create database on SQL Server instance, SQL Server engine sets the login that cr...

 
Contribute