Site icon Database Tutorials

IF Statement in SQL Server(TSQL)

 

If the condition in the “IF” block is provided, we perform operations between the “BEGIN” and “END” blocks.

You can use it as follows.

For a more detailed example, we create a table as below and add a few records. 

Then, with the help of the following script, we find the maximum age in the table and if the maximum age is greater than 50, we delete that record or records from the table.

 

Exit mobile version