sql写一个插入数据的存储过程,这样写对吗?

alterprocedure[dbo].[p_Products_InsertNew]@ProductsNamevarchar(20),@TypeIDint,@BrandI... alter procedure [dbo].[p_Products_InsertNew]@ProductsName varchar(20),@TypeID int,@BrandID int,@Color varchar(20),@Weight varchar(20),@Spec varchar(20),@Cost money,@ProductsUints varchar(20),@Material varchar(20),@UpperLimit int,@LowerLimit int,@BeginEnterDate varchar(20),@FinalEnterDate varchar(20),@LatelyOFSDate varchar(20),@UnshelveDate varchar(20),@LoadingDate varchar(20),@Description varchar(200),@Price money,@ProductsCode varchar(50),@ProductsBarCode varchar(50)asdeclare @Num intinsert into t_Products(ProductsName,TypeID,BrandID,Color,Weight,Spec,Cost,ProductsUints,Material,UpperLimit,LowerLimit,BeginEnterDate,FinalEnterDate,LatelyOFSDate,UnshelveDate,LoadingDate,[Description],Price,ProductsCode,ProductsBarCode)values(@ProductsName,@TypeID,@BrandID,@Color,@Weight,@Spec,@Cost,@ProductsUints,@Material,@UpperLimit,@LowerLimit,@BeginEnterDate,@FinalEnterDate,@LatelyOFSDate,@UnshelveDate,@LoadingDate,@Description,@Price,@ProductsCode,@ProductsBarCode), 展开
 我来答
unitech2010
2012-06-27 · TA获得超过1062个赞
知道小有建树答主
回答量:1025
采纳率:100%
帮助的人:904万
展开全部
不是用values 是用select 而且你定义的@num 好像都没有用到
create procedure [dbo].[p_Products_InsertNew]
@ProductsName varchar(20),
@TypeID int,@BrandID int,
@Color varchar(20),
@Weight varchar(20),
@Spec varchar(20),
@Cost money,
@ProductsUints varchar(20),
@Material varchar(20), @UpperLimit int,
@LowerLimit int,
@BeginEnterDate varchar(20),
@FinalEnterDate varchar(20),
@LatelyOFSDate varchar(20),
@UnshelveDate varchar(20),
@LoadingDate varchar(20),
@Description varchar(200),
@Price money,
@ProductsCode varchar(50),
@ProductsBarCode varchar(50)
as
declare @Num int
insert into t_Products(ProductsName,TypeID,BrandID,Color,Weight,Spec,Cost,ProductsUints,Material,UpperLimit,LowerLimit,BeginEnterDate,FinalEnterDate,LatelyOFSDate,UnshelveDate,LoadingDate,[Description],Price,ProductsCode,ProductsBarCode)
select
@ProductsName,@TypeID,@BrandID,@Color,@Weight,@Spec,@Cost,@ProductsUints,@Material,@UpperLimit,@LowerLimit,@BeginEnterDate,@FinalEnterDate,@LatelyOFSDate,@UnshelveDate,@LoadingDate,@Description,@Price,@ProductsCode,@ProductsBarCode
更多追问追答
追问
插入语句不是insert into表名()values()吗?select可以吗?
追答
可呀啊
你可以试一试
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式