How to modify the login account name and Sid after the SQL Server database recovers

Source: Internet
Author: User

1. Enter the Enterprise Manager of Microsoft SQL Server.
2. Select the database for which you want to restore Data, right-click the database, and select all tasks from the context menu to restore the database.
3. Select recover database from the device on the general page.
4. Select the database device to be restored, that is, the *. DUP file, and click OK.
5. Before restoring data, modify the physical file name on the option page to the actual physical file name of the database, and select force restore on the existing database.
6. Modify the objects owner and the database user ID.
Log on to the query Analyzer of Microsoft SQL Server using the SA and execute the following SQL statement:
(1) modify system parameters
Sp_configure "allow updates", 1
Go
Reconfigure with override
Go
(2) modify the objects owner (assume that the backup data of the 001 ledger is restored to the 002 ledger)
Update cwbase2.. sysusers set name = 'lc0029999'
Where cwbase2... sysusers. Name = 'lc001129'
Go
Update cwbase2.. sysusers set name = 'ad0029999'
Where cwbase2... sysusers. Name = 'ad00%9'
Go
Commit
(3) modify the Database User ID:
Update cwbase * .. sysusers set SID = Master .. syslogins. Sid
From cwbase *... sysusers, Master... syslogins
Where cwbase *... sysusers. Name = Master... syslogins. Name
Go
Commit
(4) restore system parameter settings
Sp_configure "allow updates", 0
Go
Reconfigure with override
Go
Finally, go to the maintenance tool, delete all users, register new users, and assign function and data permissions.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.