In this article i will explain about Anonymous Batches in SQL Server.
A batch is a group of sql statements. Which are executed as unit. Two types of batches are there. 1). Anonymous Batches and 2). Named Batches
1. Anonymous Batches:
A group of statements which can't be reffered by a name. Then that group/batch is called Anonymous Batches.
Begin Declare @a int Declare @b int Set @a = 10 Set @b = 20 Declare @c int Set @c = @a + @b; print 'Sum is: '+cast(@c as varchar) End
Sum is: 30
Here @a, @b, and @c are Local variables.