How to put default value for UDT? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How to put default value for UDT?

When I add a UDT, I don’t find any place to add default value. Does it mean that I need to add default value individually for any fields using that UDT?
Thanks.
After a user data type is created, you can use it in CREATE TABLE or ALTER TABLE, as well as bind defaults and rules to the user-defined data type. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
quote:Originally posted by satya After a user data type is created, you can use it in CREATE TABLE or ALTER TABLE, as well as bind defaults and rules to the user-defined data type. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.

Hi Satya, If I can put the default value during the creation of UDT, will it be a lot easier? Another question on this UDT is that what is the quicker way to change the a UDT length so all the tables contain that UDT will be using the new length. For example, I define a UDT with char(10) and add fields using this UDT to many tables. Then I decide to change the length to char(30), what do I need to do?
Thanks.
http://vyaskn.tripod.com/administration_faq.htm refer
How to change or alter a user defined data type? <top> Unfortunately, there is no easy way to alter or modify a user defined data type. To modify a user defined data type, follow these steps: Alter all the tables, that are referencing this user defined data type (UDT), using ALTER TABLE…ALTER COLUMN command and change the data type of the referencing column to an equivalent (or the intended) base data type. Drop the user defined data type using sp_droptype. Recreate the user defined datatype with the required changes using sp_addtype. Again, use the ALTER TABLE…ALTER COLUMN syntax to change the column’s datatype to the user defined data type.
Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
]]>