Blue print of IF ELSE:
IF Boolean_expression
{ sql_statement | statement_block }
[ ELSE
{ sql_statement | statement_block } ]
Original blue print:
IF (condition)
BEGIN
.........................................
END
ELSE
.........................................
Sample 1:
Declare @selecdate datetime
IF (Select top 1 salarydate from employee where empid= 'EP00001') is not null
BEGIN
select top 1 @selecdate= salarydate from employee where empid= 'EP00001'
END
ELSE
Select top 1 @selecdate= date from salarypayslip where empid= 'EP00001' and month='Jan'
select @selecdate
IF Boolean_expression
{ sql_statement | statement_block }
[ ELSE
{ sql_statement | statement_block } ]
Original blue print:
IF (condition)
BEGIN
.........................................
END
ELSE
.........................................
Sample 1:
Declare @selecdate datetime
IF (Select top 1 salarydate from employee where empid= 'EP00001') is not null
BEGIN
select top 1 @selecdate= salarydate from employee where empid= 'EP00001'
END
ELSE
Select top 1 @selecdate= date from salarypayslip where empid= 'EP00001' and month='Jan'
select @selecdate