我的商店预处理不起作用 [英] My store preocedure is not working
问题描述
我的商店程序如下
My store procedure as follows
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[Hotel_Accommodation] (@Keyword varchar(10))
as
declare @Hotelname varchar(25),
@Phoneno varchar(25),
@Roomrate varchar(25),
@CHK int,
@MSG varchar(max),
@final varchar(max),
@coursecode varchar(20),
@Accommodation varchar(20)
SET @Keyword = UPPER(@Keyword)
create table #TempTable(Hotelname varchar(25),Phoneno varchar(25),Roomrate varchar(25))
begin tran
select @CHK=COUNT(*),@coursecode = b.course_code from Tb_Course_Keyword as b where
b.Keyword = @Keyword and b.Active <> 'D' group by b.course_code
IF @CHK=0
begin
SET @MSG= 'Invalid keyword'
end
select Hotel_Name,Phoneno,Room_Rate from Tb_Accommodation where Active <> 'D'
if @MSG = ''
begin
if @Accommodation= ''
set @final = 'Dear Student, Thanks for contacting HIMT. Please Check HIMT for ' + @Keyword +
else
Set @final = 'Dear Student, ' + @keyword + + @Hotelname+ +@Phoneno+ +@Roomrate+ '- Visit www.himtmarine.com for Accommodation By HIMT'
end
else
begin
set @final = 'Invalid Keyword. Sorry try again with valid keyword or visit www.himtmarine.com.SMS HIMT xxx to 56677. Eg HIMT Accommodation to 56677'
end
select @final
当我执行存储过程错误如下
关键字'else'附近的语法不正确。
以上错误在下面的行显示如下
When i execute the store procedure error as follows
Incorrect syntax near the keyword 'else'.
The above error shows in below line as follows
if @Accommodation= ''
set @final = 'Dear Student, Thanks for contacting HIMT. Please Check HIMT for ' + @Keyword +
ELSE (This Line)
Set @final = 'Dear Student, ' + @keyword + + @Hotelname+ +@Phoneno+ +@Roomrate+ '- Visit www.himtmarine.com for Accommodation By HIMT'
请帮我解决上述商店程序中的问题。
问候,
Narasiman P.
please help me what is the problem in my above store procedure.
Regards,
Narasiman P.
推荐答案
试试这个:
Try this:
if @Accommodation= ''
set @final = 'Dear Student, Thanks for contacting HIMT. Please Check HIMT for ' + @Keyword +
删除+
Remove +
set @final = 'Dear Student, Thanks for contacting HIMT. Please Check HIMT for ' + @Keyword +
在上面的行中删除最后一行' +'
In the above line remove the last '+'
set @final = 'Dear Student, Thanks for contacting HIMT. Please Check HIMT for ' + @Keyword
if @Accommodation= ''
set @final = 'Dear Student, Thanks for contacting HIMT. Please Check HIMT for ' + @Keyword
ELSE (This Line)
Set @final = 'Dear Student, ' + @keyword + ' ' + @Hotelname+ ' ' +@Phoneno+ ' ' +@Roomrate+ '- Visit www.himtmarine.com for Accommodation By HIMT'
如其他解决方案中所述你需要在@keyword&之后删除其次,如果你需要在值之间追加空格你使用+''+。
我已经修正了上面的代码行
As mentioned in other solution you need to remove after @keyword & secondly if you need to append space in between value you using + ' ' +.
I have made the correction the above line of code
这篇关于我的商店预处理不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!