HOW TO: Change the Owner of a User-Defined Data Type That Is in Use in SQL Server 2000
2011-08-31 14:47
1006 查看
This article describes how to change the owner of a user-defined data type that
is in use.
To change the owner of a user-defined data type, you must drop
and then re-create the data type in the context of the owner you want. However,
if the user-defined data type is in use, you will receive the following error
message when you try to drop the data type:
Server: Msg 15180, Level 16, State 1, Procedure sp_droptype,
Line 32 Cannot drop. The data type is being used.
Steps to Change the Owner of a User-Defined Data Type That Is
// loadTOCNode(2, 'summary');
// ]]>
To change the owner of a user-defined data type that is in use, follow these
steps:
Script out the definition of the user-defined data type with SQL Server
Enterprise Manager (SEM).
Expand your SQL Server, expand Databases, expand your database, and
then expand User defined data types.
In the right pane, right-click the data type you want, and then click All
Tasks.
Click Generate SQL Script, and then click OK.
Select the file name and location in which you will store the script.
Determine all the tables or columns that are using the user-defined data
type by using the following code (replace the database name and data type with
your database name and data type):
NOTE: In this context, DOMAIN_NAME
represents the user-defined data type.
For each table that is using the user-defined data type, change the column
data type to the base data type by using an ALTER TABLE statement. For example
to change mytable..mycolumn to the datetimebase data type, use:
Drop the user-defined data type.
Re-create the user-defined data type by using the script you saved in step 4
under the context of the owner you want.
Change all the columns you want back to the user-defined data type by using
an ALTER TABLE statement as in step 7.
is in use.
To change the owner of a user-defined data type, you must drop
and then re-create the data type in the context of the owner you want. However,
if the user-defined data type is in use, you will receive the following error
message when you try to drop the data type:
Server: Msg 15180, Level 16, State 1, Procedure sp_droptype,
Line 32 Cannot drop. The data type is being used.
Steps to Change the Owner of a User-Defined Data Type That Is
in Use
// loadTOCNode(2, 'summary');// ]]>
To change the owner of a user-defined data type that is in use, follow these
steps:
Script out the definition of the user-defined data type with SQL Server
Enterprise Manager (SEM).
Expand your SQL Server, expand Databases, expand your database, and
then expand User defined data types.
In the right pane, right-click the data type you want, and then click All
Tasks.
Click Generate SQL Script, and then click OK.
Select the file name and location in which you will store the script.
Determine all the tables or columns that are using the user-defined data
type by using the following code (replace the database name and data type with
your database name and data type):
USE database name SELECT TABLE_CATALOG, TABLE_NAME, COLUMN_NAME, DOMAIN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DOMAIN_NAME = 'data type'
NOTE: In this context, DOMAIN_NAME
represents the user-defined data type.
For each table that is using the user-defined data type, change the column
data type to the base data type by using an ALTER TABLE statement. For example
to change mytable..mycolumn to the datetimebase data type, use:
ALTER TABLE mytable ALTER COLUMN mycolumn datetime
Drop the user-defined data type.
Re-create the user-defined data type by using the script you saved in step 4
under the context of the owner you want.
Change all the columns you want back to the user-defined data type by using
an ALTER TABLE statement as in step 7.
相关文章推荐
- Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path 解决(VS2010+IIS7.5)
- How to select the data type in SQLserver database such as varchar, nvarchar
- ERROR: The version of SQL Server in use does not support datatype 'datetime2'.
- ADO.NET Entity Framework: The version of SQL Server in use does not support datatype 'datetime2'
- Error: The version of SQL Server in use does not support datatype 'datetime2
- Error: The version of SQL Server in use does not support datatype 'datetime2'
- This function has none of Deterministic,no sql,or reads sql data in its declaration and binary logging is enabled(you *might* want to use the less safe log_bin_trust_function_creators variable
- The version of SQL Server in use does not support datatype 'datetime2'.
- 海洋工作室——网站建设专家:The version of SQL Server in use does not support datatype datetime2 and the Entity Framework.
- How to change the language of oracle sqlplus from chinese to english in windows(如何将oracle sql plus中的中文变成英文版)
- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
- CodeSnip: How to Get Id of the Record Using ASP.NET and SQL Server 2000
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection
- How to change the network IP addresses of SQL Server failover cluster instances-[From MS]
- In Oracle 11g, how to change the order of the results of a sql without “order by”?(转)
- Microsoft SQL Server 2008 R2 XML处理 One solution is to increase the number of characters retrieved from the server for XML data.
- 关于Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances的错误
- Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection