The first problem is renaming the database: You cannot rename the database directly in Enterprise Manager, you can only manipulate it in Query Analyzer
Copy Code code as follows:
Create proc killspid (@dbname varchar (20))
As
Begin
declare @sql nvarchar (+), @temp varchar (1000)
DECLARE @spid int
Set @sql = ' Declare getspid cursor for
Select spid from sysprocesses where dbid=db_id (' + @dbname + ') '
EXEC (@sql)
Open Getspid
FETCH NEXT from Getspid into @spid
While @ @fetch_status =0
Begin
Set @temp = ' Kill ' +rtrim (@spid)
EXEC (@temp)
FETCH NEXT from Getspid into @spid
End
Close Getspid
Deallocate getspid
End
--Create a process from a stored procedure
--exec killspid ' Test1 '--Invoke stored procedure close connection
--exec sp_renamedb ' Test1 ', ' Test2 '-renaming database
In this way, you can rename the database, and of course there is a way to select the database-> All tasks in Enterprise Manager-> detach the database-> clear the connection, and then directly call the
Copy Code code as follows:
exec sp_renamedb ' Test1 ', ' Test2 '
The second issue is to change the database owner problem: Select the database to change in Query Analyzer, and execute the following code to newowner the new owner
Copy Code code as follows:
exec sp_msforeachtable ' sp_changeobjectowner ', ' Newowner '
The third problem is the import and export of datasheet data: People often cause loss of database objects when importing exported data, such as primary keys, identities, defaults, and so on, by selecting the third item in the form of a table copy or query
Copying objects and data between SQL Server databases
Select Next, if you just want to operate a part of the table rather than the entire database, cancel copying all the objects this option, click the next choice to open the Select Object dialog box, in which to select the database object to be manipulated, click the following, the operation completed.
The fourth problem is replacing the field contents: If your database is injected with virus code and there is no backup, then you have to replace it yourself.
Copy Code code as follows:
Update dunktopic set field =replace (field, ' replaced content ', ' replace content ');
The fifth problem is the owner of the table in the database: In some cases, if you restore the site database, there are 80040E21 errors when you visit the site,
Error ' 80040E21 ' ODBC driver does not support required properties
It is possible that the database owner problem is causing the solution by using the method in question one to change the database owner to dbo or another user.
The sixth problem is the data restore problem, after the database restore, access to the site will inexplicably appear internal server 500 error, in fact, because the database users do not have the right to assign this database, the feature is that the database user login is not. The solution is: delete this user without a login, in Enterprise Manager's security settings, select the user who did not have the login name just now, assign it the Datawrite and Dataread permissions of the data just restored. For security reasons, it is not recommended to assign owner permissions.