In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to rename in the SQL Server database. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
The code is 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 @ @ fetch_status = 0 begin set @ temp='kill'+rtrim (@ spid) exec (@ temp) fetch next from getspid into @ spid end close getspid deallocate getspid end Program closes the connection-- exec sp_renamedb 'Test1' 'Test2'-- rename the database
You can rename the database with the above method, of course, another way is to select the database-> all tasks-> detach the database-> clear the connection in the enterprise manager, and then call the
The copy code is as follows: exec sp_renamedb 'Test1','Test2'
The second problem is to change the database owner: select the database you want to change in the query analyzer and execute the following code to newowner as the new owner
The copy code is as follows: exec sp_MSForEachTable 'sp_changeobjectowner'?', 'newowner'''
The third problem is the import and export of data tables: when people import and export data, they often lead to the loss of database objects, such as primary keys, identities, default values, etc., the solution is to choose the third option to copy objects and data between SQL Server databases in the step of table replication or query, if you only want to manipulate part of the table rather than the whole database. Cancel the option to copy all objects, click the selection below to open the Select objects dialog box, where you can select the database objects you want to operate, click next, and the operation is complete. The fourth problem is the problem of replacing the contents of the field: if your database is injected with virus code and there is no backup, you will have to replace it yourself.
The copy code is as follows: update dunktopic set field = replace (field, 'replaced content', 'replaced content')
The fifth problem is the owner of the tables in the database: in some cases, if you restore the database of the website, there is a 80040e21 error when you visit the website, and the error '80040e21' ODBC driver does not support the required properties, then it may be caused by the problem of database owner. the solution is to use the method in problem 1 to change the owner of the database to dbo or another user. The sixth problem is the problem of data restoration. After the database restore, there will be an inexplicable internal server 500 error when visiting the website. In fact, it is because there is no database permission assigned to the database user. The characteristic is that the login of the database user is gone. The solution is to delete the user who does not have a login name, select the user who did not have a login name in the security settings of Enterprise Manager, and assign it datawrite and dataread permissions for the data that has just been restored. For security reasons, it is recommended that you do not assign owner permissions.
On how to achieve renaming in the SQL Server database to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.