我正在使用 SQL Server 2008 R2 我有这样的存储过程:
CREATE PROCEDURE Get_Code_Tourne_Matin
-- Add the parameters for the stored procedure here
@The_FA int,
@The_Jour int,
@The_Insee varchar(10)
AS
BEGIN
declare @TheCode varchar(250)
set @TheCode = case
when exists (SELECT T_TOURNE_LABEL.LIBELLE
FROM TOURNE
LEFT JOIN T_TOURNE_LABEL ON TOURNE.LIB_TOURNE = T_TOURNE_LABEL.NOID
WHERE THE_FA = @The_FA AND
NO_INSEE = @The_Insee AND
JOUR = @The_Jour AND
(datepart(hh, LE_HEURE) between 13 and 23 or datepart(hh, LE_HEURE) between 0 and 6)) then LIBELLE
when exists (SELECT LIBELLE
FROM TOURNE
LEFT JOIN T_TOURNE_LABEL ON TOURNE.LIB_TOURNE = T_TOURNE_LABEL.NOID
WHERE THE_FA = @The_FA AND
NO_INSEE = @The_Insee AND
JOUR = 0 AND
(datepart(hh, LE_HEURE) between 13 and 23 or datepart(hh, LE_HEURE) between 0 and 6)) then LIBELLE
else '00'
end
RETURN @TheCode
END
我只想归还诽谤。
找到第一个带有 3 个变量的选择,然后重新运行 libelle
else 如果找到运行带有 2 个变量的选择,然后重新运行 libelle
else retrun '00'
LIBELLE 似乎有语法错误
任何的想法 ?