作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
存储过程 IF
语句不工作
@manuel varchar(50),
@tour int,
@tourname varchar(50) OUTPUT ,
@pricetax int output
AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here
if @manuel = 'no' then
SET @tourname = (select [title] from files.dbo.tours where tour = @tour)
SET @pricetax = (select top 1 [adult] from files.dbo.trprices where tour = @tour)
select distinct CONVERT(varchar(12),CAST(CAST(ddate7 AS CHAR) AS DATETIME),101) as ddate7 from files.dbo.TDEPART where tour = @tour and depart > convert(int,getdate()) and status = 'OK'
else if @manuel='yes' then
SET @tourname = (select [title] from files.dbo.tours where tour = @tour)
SET @pricetax = (select top 1 [adult] from files.dbo.trprices where tour = @tour)
select distinct CONVERT(varchar(12),CAST(CAST(ddate7 AS CHAR) AS DATETIME),101) as ddate7 from files.dbo.TDEPART where tour = 2525 and depart > convert(int,getdate()) and status = 'OK'
END
最佳答案
您需要在每个 if 和 else 之间放置一个 BEGIN 和 END,如下所示。
IF (@string = 'hello')
BEGIN
--some code
END
ELSE
BEGIN
--some code
END
希望这对您有所帮助。
关于sql - 无法使我的存储过程 IF 语句工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4935461/
我是一名优秀的程序员,十分优秀!