SQL Server 2000 creates a database with the same name, stops the database, deletes files, and Copies files. Start the database. In this case, the database has doubts. Open the query analyzer.
Exec sp_configure 'Allow updates', 1 reconfigure with override/* Turn on the system table modification switch */
Update sysdatabases set status = 32768 where name = 'describecquser'/* set database status */
DBCC REBUILD_LOG ('describecquser', 'd:/ClearQuest/becomcquser_log.ldf')/* rebuilding the LDF file */
Update sysdatabases set status = 0 where name = 'describecquser'/* reset database status */
Restore database BecomCQUser with recovery/* restore database */
Update sysdatabases set status = 16 where name = 'becomcquser'
Exec sp_configure 'Allow updates', 0 RECONFIGURE WITH OVERRIDE
If a login user is not logged on, but is in the database, the login user cannot be created or deleted. At this time, the owner of the object in the database can be changed, delete the user and create a new login.
Select the database and run the following statement to change the owner of all objects to dbo. Then, you can delete the logged-on user.
Declare tb cursor local
Select 'SP _ changeobjectowner '[' + replace (user_name (uid), ']', ']') + ']. ['
+ Replace (name, ']', ']') + '] '', ''dbo '''
From sysobjects
Where xtype in ('U', 'V', 'P', 'tr', 'fn ', 'if', 'tf') and status> = 0
Open tb
Declare @ s nvarchar (4000)
Fetch tb into @ s
While @ fetch_status = 0
Begin
Exec (@ s)
Fetch tb into @ s
End
Close tb
Deallocate tb
Go