Programming in SQL Server
Program 1.
begin
print ' welcome to SQL Programming ‘
print ' SQL Server ‘
end
Program 2.
begin
declare @a int
declare @b int
declare @c int
set @a=67
set @b = 99
set @c=@a+@b
print @a
print @b
print@c
print ' first program '
end
Program 3.
declare
@p int,@n decimal(5,2),@r decimal(5,2), @si decimal(7,2)
begin
set @p=10000
set @n=15
set @r=7.5
set @si=(@p*@n*@r)/100
print ' simple interest : ' + convert(varchar,@si)
end
Program 4.
declare
@a int,@b int,@c int
begin
set @a=50
set @b=120
set @c=35
if @a>@b and @a>@c
print ' a is big'
else if @b>@c
print ' b is big'
else
print ' c is big'
end
Program 5.
declare
@a int
begin
set @a=1
while (@a<=5)
begin
print @a
set @a=@a+1
end