本文介绍了如何摆脱这个SQL错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



这里我正在努力解决sql语法错误。我发布了 sql strore程序和错误..



请找出那个错误的地方。请帮帮我...



Dear all,

here i'm struggling with sql syntax error.here i have posted my sql strore procedure and error..

please find where's that error.Please help me...

GO
CREATE PROCEDURE SP_ADD_ENQUIRIES(
@POL VARCHAR(50),
@POD VARCHAR(50),
@FPOD VARCHAR(50),
@WEIGHT REAL,
@SHIPPER VARCHAR(150),
@CONSIGNEE VARCHAR(150)
)
AS
DECLARE @SUFFIX INT;
DECLARE @PREFIX VARCHAR(3);
DECLARE @RESULT VARCHAR(MAX);
SET @PREFIX='ENQ';
DECLARE @ENQUIRY_ID VARCHAR(MAX);
IF NOT EXISTS(SELECT * FROM ENQUIRY_MASTER)
INSERT INTO ENQUIRY_MASTER VALUES('ENQ_1',@POL,@POD,@FPOD,@WEIGHT,@SHIPPER,@CONSIGNEE)
ELSE
SET @SUFFIX=SELECT MAX(ENQUIRY) FROM ENQUIRY_MASTER;
INSERT INTO ENQUIRY_MASTER VALUES(@PREFIX+@SUFFIX,@POL,@POD,@FPOD,@WEIGHT,@SHIPPER,@CONSIGNEE)



错误是,



关键字''。


Error is,

Incorrect syntax near the keyword ''.

推荐答案

GO
CREATE PROCEDURE SP_ADD_ENQUIRIES(
@POL VARCHAR(50),
@POD VARCHAR(50),
@FPOD VARCHAR(50),
@WEIGHT REAL,
@SHIPPER VARCHAR(150),
@CONSIGNEE VARCHAR(150)
)
AS
DECLARE @SUFFIX INT;
DECLARE @PREFIX VARCHAR(3);
DECLARE @RESULT VARCHAR(MAX);
SET @PREFIX='ENQ';
DECLARE @ENQUIRY_ID VARCHAR(MAX);
IF NOT EXISTS(SELECT * FROM ENQUIRY_MASTER)
INSERT INTO ENQUIRY_MASTER VALUES('ENQ_1',@POL,@POD,@FPOD,@WEIGHT,@SHIPPER,@CONSIGNEE)
ELSE
SELECT @SUFFIX= MAX(ENQUIRY) FROM ENQUIRY_MASTER;
INSERT INTO ENQUIRY_MASTER VALUES(@PREFIX+@SUFFIX,@POL,@POD,@FPOD,@WEIGHT,@SHIPPER,@CONSIGNEE)


IF NOT EXISTS(SELECT * FROM ENQUIRY_MASTER)



with:


with:

IF NOT EXISTS(SELECT ENQ_ID FROM ENQUIRY_MASTER WHERE ENQ_ID=@EID)





替换:



Replace:

SET @SUFFIX=SELECT MAX(ENQUIRY) FROM ENQUIRY_MASTER;




with

SELECT @SUFFIX=MAX(ENQUIRY) FROM ENQUIRY_MASTER;


CREATE PROCEDURE SP_ADD_ENQUIRIES(
@POL VARCHAR(50),
@POD VARCHAR(50),
@FPOD VARCHAR(50),
@WEIGHT REAL,
@SHIPPER VARCHAR(150),
@CONSIGNEE VARCHAR(150)
)
AS
DECLARE @SUFFIX INT;
DECLARE @PREFIX VARCHAR(3);
DECLARE @RESULT VARCHAR(MAX);
SET @PREFIX='ENQ';
DECLARE @ENQUIRY_ID VARCHAR(MAX);
IF NOT EXISTS(SELECT ENQ_ID FROM ENQUIRY_MASTER WHERE ENQ_ID=@EID)
INSERT INTO ENQUIRY_MASTER VALUES('ENQ_1',@POL,@POD,@FPOD,@WEIGHT,@SHIPPER,@CONSIGNEE)
ELSE
SELECT @SUFFIX= MAX(ENQUIRY) FROM ENQUIRY_MASTER;
INSERT INTO ENQUIRY_MASTER VALUES(@PREFIX+@SUFFIX,@POL,@POD,@FPOD,@WEIGHT,@SHIPPER,@CONSIGNEE)


这篇关于如何摆脱这个SQL错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 08:29