Solved

sql server: alias data type

Posted on 2011-02-24
4
659 Views
Last Modified: 2012-05-11
i have this code
CREATE TYPE ShortDescription
FROM nvarchar(10) NOT NULL ;

create table miTabla
(id int identity,
 observacion ShortDescription)

MyTable table has 10,000 rows.
  I need to change shortDescription to nvarchar (12), as I can do?
0
Comment
Question by:enrique_aeo
4 Comments
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 34969930
Alter Table TableName
Alter column modify Columnsname DataType
0
 

Author Comment

by:enrique_aeo
ID: 34970162
I change the column observacion , but it uses an alias data type, as I can modify the alias data type?
0
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 125 total points
ID: 34971081
>> but it uses an alias data type, as I can modify the alias data type?

You can't modify a data type as it is not available per Design.
Instead the options available for you are

1. DROP TYPE and then CREATE TYPE back. But this will impact all existing tables with those types
2. ALTER TABLE to change datatype of that column to Varchar(12)

ALTER TABLE miTabla ALTER COLUMN observacion varchar(12);
0
 
LVL 9

Accepted Solution

by:
sarabhai earned 125 total points
ID: 34971227
The only way to alter a User Defined Data Type is to create a new User Define Data Type (UDDT), and change out all existing column to that UDDT, then you can drop the original one, and recreate it and change out the change you made previously.  The problem is that you can't drop the UDDT if it is in use.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question