T-SQL Programming in SQL Server:-
TSQL program is called “TSQL BLOCK”.
TSQL Blocks are two types:-
(I) Anonymous blocks
(II) Named blocks:
- DB triggers
(I) Anonymous Blocks in SQL Server :-
Declare statement :
- It is used to declare a variable.
Syntax : declare @ varname data type.
Declare @ X int
Declare @ s varchar(2) ,@ d date time.
Set statement :-
- It is used to assign value to a variable.
Set @ varname = value
Set @ x=100
Print statement :-
- It is used to print messages (or) variables.
declare @x int, @y int, @z int
Set @ x=10
Set @ y =20
Print ’sum of two nos =’+cast(@z as varchar)