Microsoft KB Archive/828815

= You receive a &quot;Database ’ already exists. (Error code:1801)

The current user or the application pool identity of the virtual server is not the owner of the database ' ' on server 'server_name\share_point'.



CAUSE
This issue may occur when the database owner of the database that you are connecting to is different from the application pool identity that SharePoint is running under.



RESOLUTION
To resolve this issue, change the database ownership and the permissions for the content database to match the identities of the virtual server accounts for content and configuration. To do this, follow these steps:
 * 1) On the computer that is running Microsoft SQL Server, click Start, point to All Programs, point to Microsoft SQL Server, and then click Query Analyzer.
 * 2) In the Connect to SQL Server dialog box, type the server name in the SQL Server box, and then click OK.
 * 3) On the Query menu, click Change Database.
 * 4) In the Select Database of   box, click the content database that you want to update, and then click OK.
 * 5) In the Query pane, type the following query.

Note In lines 3 and 4 of the query, replace \  and  \  with the domain account for the content virtual server and the domain account for the SharePoint Central Administration virtual server. If the accounts are the same, SQL Query Analyzer displays an error when you run the query, but the process still succeeds.

DECLARE @AdminVSAccount nvarchar(255)

DECLARE @ContentVSAccount nvarchar(255)

SET @ContentVSAccount = N' \ ';

SET @AdminVSAccount = N' \ ';

EXEC sp_grantlogin @ContentVSAccount;

EXEC sp_grantlogin @AdminVSAccount;

EXEC sp_changedbowner @AdminVSAccount;

IF NOT EXISTS (SELECT * FROM sysusers WHERE name=@ContentVSAccount)

EXEC sp_grantdbaccess @ContentVSAccount;

EXEC sp_addrolemember 'db_owner', @ContentVSAccount;
 * 1) On the Query menu, click Execute.

If you are running Windows SharePoint Services with WMSDE, there are separate steps to resolve the problem. In the WMSDE installation, the application pool identity for the SharePoint Central Administration is Network Service. For SQL 2000, you cannot change the database owner to Network Service because of a design limitation. The workaround for WMSDE installations is to add Network Service to the SYSADMIN role in WMSDE, add the database back by using SharePoint Manage Content databases, and then drop the role for Network Service back to its original settings.

To set Network Service as SYSADMIN, follow these steps:  Start an OSQL Session.

To do so, click Start, click All Programs, click Accessories, and then click Command Prompt. At the command prompt, start an OSQL session by typing the following syntax where  is the name of your server, and then pres ENTER:

osql -S \sharepoint -E

 Type the following command, and then press ENTER:

sp_addsrvrolemember 'nt authority\network service', 'sysadmin'

 Type go, and then press ENTER. In the SharePoint Central Administration, add the content database to the virtual server. After the content database is added back, drop Network Service role back to Security Administrators and Database Creators. Type the following command in the OSQL command prompt, and then press ENTER:

sp_dropsrvrolemember 'nt authority\network service', 'sysadmin'

</li> Type go, and then press ENTER.</li> Type quit to exit the OSQL session.</li></ol>

<div class="references_section">