--定义一个 type
create type justPK as table(PK int);
--定义一个变量对象
declare @TPpkTable AS justPK
--为表赋值
insert into @TPpkTable(PK)
select 1
union select 2
--使用的存储过程
create proc PR_Update进货物品表totalPrices
@Table justPK readonly
as
update dbo.进货物品表 set totalPrices=quantity * unitPrice where PK in(select PK from @Table)
可以通过 sys.types 查找到定义的type


本文介绍如何在SQL中定义类型和使用存储过程。首先,定义了一个名为justPK的类型,接着创建了一个变量对象@TPpkTable并为其赋值。然后,通过一个存储过程PR_Update进货物品表来更新表中的totalPrices字段。

被折叠的 条评论
为什么被折叠?



