Solved

sql server: alias data type

Posted on 2011-02-24
4
658 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to simplify my SQL statement? 14 50
Minus first query 1 36
Help with SQL - TOP 10 by date and by group 13 31
testing sql16 on win10 vs OS16 2 32
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

948 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now