我正在尝试将我的电子邮件附加到我的@email 字符串中,传入了错误的@status。它可以在没有我注释掉的行的情况下工作。我想我很接近,但语法错误。@override_email 为空。
DECLARE @retval INT
DECLARE @email nvarchar(200)
DECLARE @override_email nvarchar(200) = null
DECLARE @status INT = 2
DECLARE @in_customer_id INT = 160308
SET @email = COALESCE(@override_email, (
SELECT
COALESCE(CustomerDetail.Email, '')
/*+ (if @status NOT IN (3,4,5) ', alex@email.com')*/
FROM
tbl_customer_detail CustomerDetail
WHERE
CustomerDetail.customer_id = @in_customer_id))
select @email