Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to alter user defined table types

I have already tried to alter the user defined table types but it is not working with alter commend.

alter TYPE [dbo].[GriDDateTab] AS TABLE(
    [Application [varchar](50) NOT NULL,
    [LandDist] [char](2) NULL,
    [Land] [char](3) NULL,
    [LandVi] [char](4) NULL)
like image 756
ganesh Avatar asked Apr 25 '15 13:04

ganesh


People also ask

Can we ALTER TABLE type in SQL?

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. The ALTER TABLE statement is also used to add and drop various constraints on an existing table.

What are user-defined table types?

User-defined table types are the predefined tables that the schema definition is created by the users and helps to store temporary data. User-defined table types support primary keys, unique constraints and default values, etc.


2 Answers

You have to drop and recreate. That means if you have any references (eg stored procedures) using the type, that reference must be removed first.

like image 143
dmeglio Avatar answered Sep 18 '22 12:09

dmeglio


The bad news is that you have to drop and re-create as SQL server does not (at least not up until 2012 support this.

The good news is that stored procedures and functions should pick up table type changes on the fly with no need to drop and re-create.

like image 37
Ed Green Avatar answered Sep 20 '22 12:09

Ed Green