A Batch is a collection T-Sql statements can be written and executed as a single unit
A batch may be
1. Anonymous Batch / Name less Batch
2. Named Batch
Anonymous Batch / Name less Batch:
Set of T-Sql statements can written and executed as a single unit without any proper name Anonymous batch or Nameless batch.
Variable:Variable is nothing but a memory element, which can be varied through out the program execution.
Types of variables:
In Sql Server there existed two types of variables.
A. Global variables: These are the variables which can be accessible by any user, any database, any function, any procedure. These variables are preceded by a special symbol ‘@@’. These are also known as “Public variables”.
Examples:
select @@Servername
select @@Version
select @@Language
………………………….
…………………………………
B. Local variables: These are the variables which can be accessible by particular user, particular database, particular function, and particular procedure. These variables are preceded by a special symbol ‘@’. There are also known as “Private variables”.
Syntax: to declare the local variables:
Declare @varaiblename datatype,………….
Example: declare @x int, @y varchar(20)
Syntax to assign the values:
Set @variablename = value/expression
Example:
Set @x=125
Set @y=’NRSTT’
Set @z=@A+@B
Print statement:
This statement is used for printing the output in result window.
Syntax: Print @ variablename/constant
Example:
print @x
print @y
print ‘sqlserver’
comments:
In sql server comment is nothing but a non-executable statement we can make a single line / multiple lines as comments
--for single line comment
/*------------
----------*/ for multiple line comments
No comments:
Post a Comment