[英]Error in stored procedure in SQL Server 2008
I created a type named detalleList
and I need to use it in a stored procedure but I get an error. 我创建了一个名为detalleList
的类型,需要在存储过程中使用它,但出现错误。 What am I doing wrong? 我究竟做错了什么?
This is detalleList
type 这是detalleList
类型
CREATE TYPE [dbo].[detalleList]
AS TABLE ([idCcompVtaD] [bigint] NULL,
[idProducto] [bigint] NULL,
[cantidad] [int] NULL,
[precio] [decimal](18, 2) NULL,
[precioTotal] [decimal](18, 2) NULL)
CREATE PROCEDURE [dbo].[SP_GrabarFactura]
@List as dbo.detalleList readonly,
@Fecha datetime,
@total decimal(18,2),
@notas varchar(200),
@idUsuario bigint,
@idCliente bigint,
@new_identity INT = NULL OUTPUT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO ccompvta (fecha, total, notas, idUsuario, idCliente)
VALUES (@Fecha, @total, @notas, @idUsuario, @idCliente);
SET @new_identity = SCOPE_IDENTITY();
INSERT INTO dcompvta (idCcompVta, idProducto, cantidad, precio, precioTotal)
SELECT
(@new_identity,
idProducto, cantidad, precio, precioTotal)
FROM @list;
END
Error: 错误:
Msg 102, Level 15, State 1, Procedure SP_GrabarFactura, Line 19 消息102,第15级,状态1,过程SP_GrabarFactura,第19行
Sintaxis incorrecta cerca de ','. Sintaxis errorsa cerca de','。
In the last line you have some parenthesis too much: 在最后一行,您的括号太多了:
select (@new_identity, idProducto,cantidad,precio, precioTotal) from @list;
Should be 应该
select @new_identity, idProducto,cantidad,precio, precioTotal from @list;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.