我寫了一個存儲過程,我越來越近線64不正確的語法錯誤的語法提交在存儲過程中
CREATE PROCEDURE dbo.Transactions_Create
(@AccountID INT, @EmplNo smallint,@Amount Money,@Description VARCHAR(100),@EnteredBy VARCHAR(41),@Type char(1),
@TransId INT OUTPUT)
AS
SET XACT_ABORT ON;
BEGIN Transaction
Declare @ActType dbo.AccountType
select @ActType =Type from dbo.Accounts
where [email protected];
Declare @Withdraw smallint
select @Withdraw
=WithdrawalCount from dbo.Accounts
where [email protected]
Declare @ServiceFee Money
Declare @withdrawchange smallInt
Declare @balancechange Money
if @Type='D'
BEGIN
SET @ServiceFee=0.0;
SET @withdrawchange=0;
SET @[email protected];
end;
else
BEGIN
SET @withdrawchange=1;
if @ActType='cheaquing'
begin
SET @ServiceFee=0.50;
end
else
begin
if @Withdraw<2
begin
SET @ServiceFee=0.0;
end
else
begin
SET @ServiceFee=1.00;
end
SET @balancechange=(@[email protected])*-1;
end
update dbo.Accounts
SET Balance= [email protected], [email protected]
where [email protected];
INSERT Into dbo.Transactions(AccountID, EmplNo ,Amount, Description ,EnteredBy ,Type)
values (@AccountID, @EmplNo ,@Amount, @Description ,@EnteredBy ,@Type);
SET @TransID = SCOPE_IDENTITY();
commit Transaction;
我不知道什麼是錯我的語法。一切看起來都是正確的,從我所理解的一切都應該進入BEGIN TRANSACTION COMMIT TRANSACTION塊,所以我不明白爲什麼這是失敗的
我猜你的'end's不與'begin's排隊。 –
閱讀錯誤消息。考慮錯誤信息並將「問題」分解成更小的部分,直到確定實際問題區域。修復問題,並重新構建代碼/語法/查詢,確保不會再次破壞它。如果仍然存在問題(識別出一些相關的代碼後),然後詢問*幷包括相關的錯誤*。 – user2864740