나는 SQL Server 2005에서 저장 프로 시저를 다음 쓴 나는 오류 메시지가 얻을 : 잘못된메시지 102, 수준 15, 상태 1,
메시지 102, 수준 15, 상태 1, 프로 시저 sp_InsertCustTrans, 라인 (12)
을 구문은 '@TrID'근처에 있습니다.
내 저장 프로 시저는 다음과 같습니다
ALTER PROCEDURE [dbo].[sp_InsertCustTrans]
-- Add the parameters for the stored procedure here
@CuID int, @TrType nvarchar(10), @TrAmt int
AS
BEGIN
SET NOCOUNT ON;
declare @TrID int;
Select @TrID = MAX(TransactionID) from CustTrans;
if Isnull(@TrID)
@TrID = @TrID + 1
else
@TrID = 1
-- Insert statements for procedure here
if (@TrType = 'Deposit')
begin
INSERT INTO CustTrans (TransactionID, TransactionDate, CustID, TransactonType, CreditAmount)
Values(@TrID, GetDate(), @CuID, @TrType, @TrAmt);
end
else
begin
INSERT INTO CustTrans (TransactionID, TransactionDate, CustID, TransactonType, DebitAmount)
Values(@TrID, GetDate(), @CuID, @TrType, @TrAmt);
end
END
GO
수동으로 ID를 증가시키는 것은 끔찍한 생각이며 경합 조건에 개방적입니다. 동기화 계획이 있다고 가정합니까? – ChaosPandion