2017-12-19 1 views

답변

0

당신은 이런 식으로 작업을 수행 할 수 있습니다

if @check <> 0 
    SET @email = '[email protected]' 
else 
    SET @email = '' 

는 SQL Server의 this article에 대한 IF...ELSE...에서보세요.

+0

도움 주셔서 감사합니다. 그것은 작동합니다. –

1

사용이

Declare @check as int; 
Declare @email as varchar(50); 

if(@check!=0) 
BEGIN 
    set @email='[email protected]'; 
END 
ELSE 
BEGIN 
    set @email=''; 
END 

그것은 BEGIN 및 END하지만 언제

0

당신은 또한 CASE를 사용하여 가독성과 쉬운 이해를 위해 권장해야 할 의무 아니다 대신 시작 {및 END 대신} ...

SELECT @email = CASE WHEN @check <> 0 THEN '[email protected]' else '' END 
관련 문제