How do I change the " user-defined data type " ower to dbo?

Source: Internet
Author: User
Tags commit rollback rowcount
Data | data type
Method 1. Delete First, then re-establish
if exists (SELECT * from dbo.systypes where name = N ' Dt_ac_area ')
EXEC sp_droptype N ' ssn '
Go
SETUSER--The default is dbo
Go
EXEC sp_addtypen ' Dt_ac_area ', n ' char (3) ', n ' not null '
Go

Method 2. Delete SRX User Defined Data Types directly through the database all mountains:
Use master
Go
EXEC sp_configure ' allow updates ', ' 1 '
Go
Reconfigure with OVERRIDE
Go
Use T--database name
Go
BEGIN TRANSACTION
Delete systypes where uid=user_id (' SRX ')
If @ @rowcount <>0
Commit TRANSACTION
Else
ROLLBACK TRANSACTION
Go
Use master
Go
EXEC sp_configure ' allow updates ', ' 1 '
Go
Reconfigure with OVERRIDE
Go


Also forget that if you don't want to delete, you can update the DBO directly with the second method:

Use master
Go
EXEC sp_configure ' allow updates ', ' 1 '
Go
Reconfigure with OVERRIDE
Go
Use T--database name
Go
BEGIN TRANSACTION
Update systypes SET uid=1 where uid=user_id (' SRX ')--Update directly
If @ @rowcount <>0
Commit TRANSACTION
Else
ROLLBACK TRANSACTION
Go
Use master
Go
EXEC sp_configure ' allow updates ', ' 1 '
Go
Reconfigure with OVERRIDE
Go




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.