mssql2000升级到SQLServer2005数据库中更改数据架构方法
数据库升级到 mssql 2005 了,我对 2005 不熟悉,发现还原 2000 的数据以前的用户名删除不了,报 Microsoft SQL Server错误: 15138。
在网上找到:SQL Server 2005删除用户失败解决方法(15138错误)
Microsoft SQL Server错误: 15138删除对于用户失败,数据库主体在该数据库中拥有架构,无法删除。
删除 对于 用户“*****”失败。 (Microsoft.SqlServer.Smo)
其他信息:
执行 Transact-SQL 语句或批处理时发生了异常。 (Microsoft.SqlServer.ConnectionInfo)
解决方法一
先删除此用户对应的架构,然后在删除对应的用户
步骤
代码如下 | 复制代码 |
1。SQL SERVER MANAGEMENT STUDIO -> 数据库 -> 安全性 -> 构架,先删除对应的构架 2。SQL SERVER MANAGEMENT STUDIO -> 数据库 -> 安全性 -> 用户,删除对应的用户 |
解决方法二
–执行如下SQL语句
ALTER AUTHORIZATION ON SCHEMA::db_owner TO dbo;
–然后手动删除就可以了。
在这里又出现构架也删除不了,原因有一个表的构架不是 dbo 了,得改为 dbo 才行。
在数据库testDB中存在架构A及用户A,现将testDB数据库所属的用户由A改为B,同时删除用户A;
架构也由A改为B,删除架构A,操作如下:
1、创建用户B,再创建架构B;
2、将架构A的权限赋给用户B,取消用户A拥有架构A的权限,删除用户A;
3、将数据库的所有属于架构A的对象改为架构B,代码如下:
ALTER SCHEMA [新架构名] TRANSFER 旧架构名.[数据库中的对象表或视图或存储过程]
ALTER SCHEMA [B] TRANSFER A.[对象1]
ALTER SCHEMA [B] TRANSFER A.[对象2]
ALTER SCHEMA [B] TRANSFER A.[对象n]
而当要更改一个数据库中全部的表或存储过程时,用上面的方法是可以实现,但是速度太慢了,所以写了一个存储过程批量修改:
改存储过程:
代码如下 | 复制代码 |
USE [testDemo] -- --ALTER SCHEMA slqwell TRANSFER create table #t ( ID int IDENTITY (1,1) not null, --创建列ID,并且每次新增一条记录就会加1 procName varchar(100), ) insert into #t(procName) select 'dbo.' +name from sysobjects where xtype='P' and status>=0 select * from #t declare @i int declare @j int set @j = 1 declare @procName varchar(100) declare @SchemaTable varchar(200) while(@j begin select @procName=procName from #t where ID=@j set @j = @j + 1 set @SchemaTable = 'ALTER SCHEMA sqlwell TRANSFER ' + @procName exec (@SchemaTable) end drop table #t |
其中原来的架构为代表dbo,先的为sqlwell
要修改表的架构时,只要修改上面的xtype='P' 为xtype='U'

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When using Win11 system, sometimes you will encounter a prompt that requires you to enter the administrator username and password. This article will discuss how to deal with this situation. Method 1: 1. Click [Windows Logo], then press [Shift+Restart] to enter safe mode; or enter safe mode this way: click the Start menu and select Settings. Select "Update and Security"; select "Restart Now" in "Recovery"; after restarting and entering the options, select - Troubleshoot - Advanced Options - Startup Settings -&mdash

In the early days of social media, you could change your profile name multiple times, but now changing your name on any social media app comes with its own set of restrictions. If you've been wanting to change your display name or username on Instagram, the post below will explain how often you can change them, how to do it, and what you can do when you can't change your name on the platform . How to change display name and username on Instagram? Instagram offers two places for your name - your display name and your username, and luckily you can change both easily in the mobile app. The display name is what you would normally enter true

OOBE or out-of-box experience is a process designed for users to guide them through the various stages of post-installation steps. This includes rights and agreement pages, login pages, WiFi or network connection options, etc. If you receive any OOBEKeyboard, OOBELOCAL, or OOBEREGION issues, you will not be able to proceed to the final installation steps. Don't worry. There are some simple fixes you can use to resolve this issue. Workarounds - Before you do anything else, try these normal solutions - 1. When you get an error prompt, go ahead and click on the "Try Again" prompt. Keep trying at least 7 to 8 more times. 2. Check network connectivity. If you are using an Ethernet connection or Wi-Fi

Nowadays, many Windows users who love games have entered the Steam client and can search, download and play any good games. However, many users' profiles may have the exact same name, making it difficult to find a profile or even link a Steam profile to other third-party accounts or join Steam forums to share content. The profile is assigned a unique 17-digit id, which remains the same and cannot be changed by the user at any time, whereas the username or custom URL can. Regardless, some users don't know their Steamid, and it's important to know this. If you don't know how to find your account's Steamid, don't panic. In this article

How to fill in the user name of Railway 12306? You can fill in the user name in Railway 12306 APP, but most friends don’t know how to fill in the user name of Railway 12306. Next is the graphic tutorial on how to fill in the user name of Railway 12306 brought by the editor. , interested users come and take a look! Railway 12306 usage tutorial How to fill in the Railway 12306 username 1. First open the Railway 12306 APP and click [Register] at the bottom of the main page; 2. Then on the registration function page, enter the user name, password, confirmation password, etc.; 3. Finally enter Once completed, you can fill in the user registration.

The wifi username refers to the administrative username of the wireless router. This username, the IP address of the router, and the default administrative password are usually printed on the bottom of the wireless router and can also be found in the manual of the wireless router; the default administrative user of most routers The name is both admin, and the management password is also admin.

Instagram is one of the social media giants primarily based on photo and video sharing. People browse high-quality photos through apps, now using Instagram Reels and IGTV, with short and long videos. It has also become a big source of income for many people around the world through advertising and how they capitalize on their growing number of followers. The app is very addictive and you can spend hours just browsing the app. The Instagram app allows you to choose a new username and also a new name. The main difference between a name and a username is that a username is the title of your profile, while a name is a description of what your profile represents. Here, let’s see how to change your name using an Android phone.

How to change username in Google Chrome? Nowadays, more and more people like to use Google Chrome. This browser can provide users with rich functions and services. Users can experience all the functions after logging in to their account. Many users just pick one when creating an account. Nickname, I believe everyone wants to know how to change the username later. This article will introduce to you the steps to quickly change your username on Google Chrome. You may wish to take a look and learn more. Introduction to the steps to quickly change the username in Google Chrome 1. In the first step, after we open Google Chrome, open the three vertical dot icons in the upper right corner of the page (as shown in the picture). 2. In the second step, after opening the three vertical dots icon, we click to open the "Settings" option in the menu list (as shown in the figure)
