I'm getting a little problem making my stored procedure..
I'm making a stored procedure for copy all the records that I have on the Carrinho table to the DocumentosArtigos table.
I have an image that discribes what I want:
I made some code with a little help and I have this now:
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE PROCEDURE e_TransformaCarrinho
-- Add the parameters for the stored procedure here
172312 as CHAR(5)
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @I INT
SET @I = 0
SELECT 'T', 50 ,CodDocumentoID, @I, ArtigoID, NomeArtigo, Quantidade,
CASE WHEN CodDocumento = 1 THEN 'PVP' WHEN CodDocumento = 2 THEN 'PC' END,
0, 0, 0, 0.21, (Quantidade*PVP+(Quantidade*PVP*0.21)), 0, (Quantidade*PVP*0.21), 0, 0
WHERE UserID = 172312
I'm getting the folowing error:
Msg 515, Level 16, State 2, Procedure tgDocumentosArtigos_Insert, Line 28
Cannot insert the value NULL into column 'PrUnitario', table 'EINAUS.dbo.DocumentosArtigos'; column does not allow nulls. INSERT fails.
The statement has been terminated.
I think the SP ig going to work I only don't know if @I will be sequencial.. is it?
A Happy 2007 to everyone!
Thanks in advance for the replys