0

Is there a way to alter (drop and create) user defined Table type without dropping dependent object.

I have this table type

CREATE TYPE [dbo].[ttOrderItems] AS TABLE(
    [Position] [int] NULL,
    [ItemCode] [varchar](16) NULL,
    [QtyOrdered] [int] NULL,
    [UOM] [varchar](2) NULL,
    [PriceQuoted] [decimal](10, 2) NULL
)

and dependent table type function

CREATE function [dbo].[ftCatalogItems](@comno varchar(3),@cuno varchar(6),@items  ttOrderItems readonly) returns table as
/*-------------------------------------------------------
DECLARE @COMNO VARCHAR(3)='010',@CUNO VARCHAR(6)='000164'
declare @items ttOrderItems;
select * from @items
insert @items
select '1231-221',1,'EA',20.20
union  select '110223-245',10,'EA',2001.20
--------------------------------------------------------*/
return(
    select Position,ItemCode,QtyOrdered
        ,PriceQuoted
        ,Net
        ,t$qanp QtyApplicable
        ,Status=case 
                when t$item is null then 'Not in Catalog' 
                when t$stdt > getdate() then 'Availle only on or after '+Convert(varchar(30),t$stdt,106)
                when  datediff(DD,getdate(),isnull(nullif(t$tdat,''),'4712-01-01')) < 1 then 'EXPIRED'
                when items.PriceQuoted != Net then 'Quoted Price do not match Catalog price'
                else Null
            end 
    from @items items
    Left Join ediCatalog c on ltrim(c.t$item)=ItemCode AND COMNO=@COMNO AND T$CUNO=@CUNO  and c.[Server]=dbo.fsBaanServer()
)

Now I want to alter (drop/create) the type ttOrderItems,. How can I do this without first dropping the ftCatalogItems ?

TonyP
  • 5,655
  • 13
  • 60
  • 94

3 Answers3

1

As per my knowledge it's not possible.

http://msdn.microsoft.com/en-IN/library/ms174407.aspx

ram_sql
  • 404
  • 2
  • 9
0

To Alter table name

sp_rename old_table_name, new_table_name
Dinesh Reddy Alla
  • 1,677
  • 9
  • 23
  • 47
0

You could temporary delete the dependencies and then re-create them. You could automate this process, see my answer here.

Community
  • 1
  • 1
BornToCode
  • 9,495
  • 9
  • 66
  • 83