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),
展开
1个回答
展开全部
不是用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
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可以吗?
追答
可呀啊
你可以试一试
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询