In this article, we will learn the notions and usage details of the SQL variable. In SQL Server, local variables are used to store data during the batch execution period. The local variables can be created for different data types and can also be assigned values. Additionally, variable assigned values can be changed during the execution period.
The life cycle of the variable starts from the point where it is declared and has to end at the end of the batch. On
the other hand, If a variable is being used in a stored procedure, the scope of the variable is limited to the
current stored procedure. In the next sections, we will reinforce this theoretical information with various examples
Read more »