How to Work With IF ELSE Statement in Transact-SQL

In this article I am going to explain about how to work with IF ELSE statement in Transact-SQL.
  • 2259


Transact-SQL (T-SQL) is Structured Query Language and it is Microsoft's and Sybase's proprietary. Transact-SQL is originally developed by IBM for querying, altering and defining relational database. Transact SQL is also known as T-SQL. T-SQL supports many feature like variables, loops, conditions  and exceptions.  

T-SQL provide the fallowing feature

  • Stored Function
  • Stored procedure
  • Trigger
  • Index
  • View

T-SQL provide the programming concept. It also provide a wide variety of data types for variables and constants. SQL provide limited support for advance programming and T-SQL fill this gap.  

IF ELSE statement

IF ELSE statement in T-SQL is the most basic of all the control flow statements. IF ELSE statement execute a sequence of statement depending upon condition.



@emp_id int = 200,

@emp_sal money 

if(@emp_id>0 and @emp_id<100)


print (' Name and salary ' )

select name,salary from mcnemp where id = @emp_id




print('employee id is not correct')


© 2020 DotNetHeaven. All rights reserved.