CREATE PROCEDURE stor1
@@a int(20),
@@b int(20),
@@c int(20)
AS
set @@a=(select sum(数量) from purchase where 商品名称 in (select 商品名称 from product))
set @@b=(select sum(数量) from sale where 商品名称 in (select 商品名称 from product))
set @@c=@@a-@@b
UPDATE product SET 库存=@@c
GO
@@a int(20),
@@b int(20),
@@c int(20)
AS
set @@a=(select sum(数量) from purchase where 商品名称 in (select 商品名称 from product))
set @@b=(select sum(数量) from sale where 商品名称 in (select 商品名称 from product))
set @@c=@@a-@@b
UPDATE product SET 库存=@@c
GO
运行你的代码是数据类型不对。
错误提示为 @@a不能指定数据宽度
.
.
@@a数据类型不对
函数convert()
@@a int,
@@b int,
@@c int
AS
set @@a=(select sum(数量) from purchase where 商品名称 in (select 商品名称 from product))
set @@b=(select sum(数量) from sale where 商品名称 in (select 商品名称 from product))
set @@c=@@a-@@b
UPDATE product SET 库存=@@c
GO---你的
@@a int(20),
@@b int(20),
@@c int(20) 为什么要这样写呢???
CREATE PROCEDURE stor1
@a int,
@b int,
@c int
AS
set @a=(select sum(数量) from purchase where 商品名称 in (select 商品名称 from product))
set @b=(select sum(数量) from sale where 商品名称 in (select 商品名称 from product))
set @c=@a-@b
UPDATE product SET 库存=@c
GO
现在结贴!HOHOHO