Posts tagged "if-else"

Using if-else Statement while Inserting the Record in SQL Server Database

Today we will learn that how to use an if-else statement while inserting records into the database. We are talking about the SQL Server database. To understand this example we are understanding a problem that will make easy to  learn if-else statement. Our problem is we want to insert a record into the table named “StudentRecord”. This table have two columns named ‘student_name’ and ‘student_gender’. We will pass the name and gender as parameter in the stored procedure. Now we have to edit the name according to his/her gender. for example if the student_gender = ‘Male’ then we will add ‘Mr.’ before the name of student. Similarly if the student_gender = ‘Female’ then we will add ‘Mrs/Miss’ before the name of student. Now we are showing that how this task will be done.

Read More →

Implementing If-Else Statements in T-SQL(MS SQL Server)

Control-of-flow statements are very must for any programming language. A complete project can not be completed without any condition. And when we talk about the condition there are various types of control statements in T-SQL. Today we will discuss first If statement then If-Else statements in T-SQL. If-Else statements do the same task as for any other language. It checks for a condition if the condition is true then execute the “IF” part otherwise executes the “ELSE” part. And then we will learn how to grouping code into blocks so that we can perform various operation in single If or Else condition.  Read More →