是否有办法在不丢弃依赖对象的情况下更改(删除和创建)用户定义的表类型。
我有这个表类型
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
)
和依赖表类型函数
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()
)
现在我想改变(删除/创建)ttOrderItems类型。如何在不先删除ftCatalogItems的情况下执行此操作?
答案 0 :(得分:1)
答案 1 :(得分:0)
更改表名
sp_rename old_table_name, new_table_name
答案 2 :(得分:0)
您可以临时删除依赖项,然后重新创建它们。您可以自动完成此过程,请参阅我的回答here。