SQL Server batch modify table names

Source: Internet
Author: User
Tags mssql server

If you want to change the prefix of "SQL" table "ABC _" to "def"

First use SQL statements to query all tables with the "ABC _" prefix

Select * From sysobjects where xtype = 'U' and name like 'abc _ %'

Then modify the statement

Update sysobjects set name = Replace (name, 'abc _ ', 'def _') Where xtype = 'U' and name like 'abc _ %'

If the statement is run, "Special updates to the system directory are not enabled. The system administrator must reconfigure SQL Server to allow this operation. There are two ways to solve this problem:

 

Method 1:
Open MSSQL Server properties --- server options ---- enable special updates to the system directory (allow direct modifications to the system directory. (PS: Enterprise Manager --- tools --- SQL Server Configuration properties --- server settings --- allow direct modification to the system directory) and then execute the SQL statement in the query analyzer.

Method 2: run in the query Analyzer

Sp_configure 'Allow updates', 0 -- the value cannot be modified.
Sp_configure 'Allow updates', 1 -- allow modifications to the system table
Reconfigure with override -- update the current configuration of the configuration option changed using sp_configure system stored procedure

 

Refresh the target table.

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.