Sql all Command coding , SQL 2005 All Command Collection

Unique Code of All query in SQL

Hello friend , I want to describe all Query of SQL in easy and friendly way . I think it is most helpful for new user of SQL learner.  I give the well know database name and  table name here My name and other person name for Easy Instruction.

SQL Query Code Collection, SQL all Query Coding, Collection of SQL Online

So First of all you should have sql server 2005 or 2008 for this given code. I describe here for sql server 2005, here. So Open sql server 2005 and   Connect the local server whis you installed you on your system simply click on connect button.
Now you are connected to database server.

Now I want to create Each and every things step by step . you have to follow the given coding and run the program/ query

Now start  how to create database  :- create new query button on the top corner button
Now you are on coding page

here let's start to create query
So First of all Create a New Database  : here i created a databas name 'AmitSaxena' type the code as

create database AmitSaxena 

Now Select all above line and press F5 button or go to query menu and select Excute button or define exeute button on toolbar.

simply here Press F5 Button to run. you will get a message below database created successfully .

Now How to use your created database so write the following code

use AmitSaxena

and select it all and press F5 Button Now you entered your database Name AmitSaxena

Note:(What is database-) Data base is collection of Many table which has a unique name of table. In One database we can create a only one table in same name no other create table as same name you will have to create a new table with new name.)

=>Now How to create table in database

create table Amit
Sid int,
Name char (20),
Age int,
City char(25),
Salary money

Select All And press F5 Button , You will get success full message below.

=>Now How to Insert Values in above Table Amit , So write the Code as show below and inter some values in the table as here.

insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(2,'Ajit kumar',13,'Pali', 5000)
insert into Amit values(3,'Raj kumar',15,'Patna', 10000)
insert into Amit values(4,'Mukesh kumar',21,'Arwal', 15000)
insert into Amit values(5,'Pankaj kumar',19,'Delhi', 20000)
insert into Amit values(6,'Anup kumar',3,'Mumabai', 100)
insert into Amit values(7,'Samal kumar',14,'Ilahabad', 12000)
insert into Amit values(8,'Sujit kumar',29,'Chenai', 24000)
insert into Amit values(9,'Satish kumar',19,'Bokaro', 30000)
insert into Amit values(10,'Rahul kumar',23,'prayag', 32000)
insert into Amit values(11,'Prem kumar',29,'Danbad', 22000)
insert into Amit values(12,'Dipak kumar',12,'Jaipur', 13000)
insert into Amit values(13,'Arbind kumar',10,'Kolkata', 9000)
insert into Amit values(14,'Mantu kumar',25,'Aurangabad', 14000)
insert into Amit values(15,'Muradabad kumar',32,'Rohtas', 11000)
insert into Amit values(16,'Pankaj kumar',42,'goh', 40000)
insert into Amit values(17,'Nirjan kumar',9,'Bhopal', 23000)
insert into Amit values(18,'yadu kumar',39,'Bikarm', 53000)
insert into Amit values(19,'Tnku kumar',43,'Sahrsa', 43000)
insert into Amit values(20,'Hari kumar',49,'Banglore', 10500)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)
insert into Amit values(1,'Amit kumar',19,'Paligang', 10000)

Note :  select line by line or select all and press F5 To Run the program.
Now I want to tell you how to See the Inserted values from the table;

Important Instruction:  here friend I want to say you that sql server main view of query the data from the database so there is many way to see the value of data base so I  describe on same database and table . You can create a lots database and table as above Instruction so i am going to tell how to see all value in the table; 
One thing More friend , here i can not describe again how to create database and table so you should have remember above code or visit code for it. so take this matter.

=>How to see all values from data base ,write the following code as below.

Select*from Amit 

select all and press F5 button to run this code after that you see the all value which you inserted in the table.

=>How to change the column name of the table write the colde and select all and press F5 Button.

select 'MyName'= Name from Amit

Now you see the change column name of the original table.

=> Now Friend I want to describe here some distinct value from the database you can call it mathematical based value from the database. It is more useful and instant  wishing value from the table, so write the code as below and select code line and press F5 for the result. 
Important Instruction :-here you take care ,  I created all query on same table name Amit and database name Amitsaxena So if you want to query the all  then you have to create a table which have about 50 row values in the table that should have Following Column Name and datatype (Id/roll numbe Int data type for must for this query so you must have created this type of table other wise you have get an error message. but don't worry ,if value in the table available then it must show the wishing value other wise it gives error message)

select*from Amit where Salary between 20000 and 50000
Select Max(Salary) from Amit
Select Min(Salary) from Amit
Select Sum(Salary)from Amit
Select Avg(Salary)from Amit
Select Max (Age)from Amit
Select Min (Age) from Amit
Select Salary,  bonusSalary = Salary+5000 from Amit

select*from Amit where salary >20000
select *from Amit where Salary >=20000
Select*from Amit where salary<20000
select*from Amit Where salary<= 20000
select *from Amit where salary!<20000
Select *from Amit where Salary !> 20000
Select*from Amit where Salary !=20000
select *from Amit where salary > 25000 and age >25
select *from Amit where salary > 20000 and age >13
select *from Amit where city in('patna', 'delhi')
select *from Amit where city not in('patna', 'delhi')
select *from Amit where age in(20)
select *From Amit where age not in(20)and city not in('Patna','delhi')
select *from Amit where age in (20) or city  not in('delhi')
select *from Amit where age in (20) or city   in('delhi')

select *from Amit where name like '%A%'
select *from Amit where name like 'A%'
select *from Amit where name like 'A-'
select*from Amit
Select *from Amit where name like 'A[m]t'
Select *from Amit where name like 'A[^h]'
select distinct age from Amit
select distinct Name from Amit
select *from Amit order by age Asc
select *from Amit order by age   Asc
select *from Amit order by salary Asc 
select *from Amit order by Salary desc
select *from Amit order by age desc
select top 3*from amit order by age asc
Select top 3*from amit order by salary desc
select top 3* from amit order by age desc
select 'your id is; '+Name+' comes from '+city from Amit

=> create table which not allowed null value in the table , Null means , if you not insert the all value of your all column then it give you error message.

// Create table which not allow null value//
Create Table Amit1
Name char(24) not null,
City char(26) not null,
Address char(500),
Mobile varChar(32)


Insert into Amit1 values
('Amit','Patna','Village amar pura, post makhmilpur, police station paliganj district patna i read in  class bscit in niit boring road crossin which is
situatued in patna in bihar',
select*from Amit1

=> How to delete table from database

Drop table Amit1

=> Now I want to provide you some string function that run from computer compiler which is all ready defined by system; Some are here below:

you select the following line 1 by 1 and press the F5 button to see the result.

//string function//

select ascii('A')
select ascii('b')
select ascii('a')
select ascii('B')
select ascii('c')
select ascii('D')
select ascii('d')
select ascii('E')
select ascii('')

select ascii('Amit')
select char(98)
select char(230)
select char(500)
select char (234)
select char (35)
select char (24)
select char (34)
select char (4)
select char (2)
select charindex('a','Captain')
select charindex('p','Captain')
select difference('Amit', 'Anil')
select difference('Amit', 'Amit')
select left('AmitSaxena',3)
select left('AmitSaxena',1)
select right('AmitSaxena',3)
select len('AmitSaxena')
select len('I am a good boy of my class')
select lower('SAShi')
select upper('amitsaxena amarpura paliganj')
select Ltrim('    Amit')
Select Ltrim('Amit ---  ')
select rtrim('Rahul    raj')
select patindex('%ha%', 'bhushan')
select patindex('%ha%', 'bhushan')
select patindex('%an%', 'bhushan')
select reverse('Mohan')
select upper(reverse('Amit'))
select 'Amit'+space(10)+'Saxena'
select str(234.432,6,2)
select stuff('Katrina', 3,2,'m')
select substring('rohan',2,2)
select @@version

select getdate()
select dateadd(mm,3,'2009-02-03')
select dateadd(dd,11,'2009-12-23')
select difference('2010-10-04','1992-03-05')
select dateadd(yy,3,'2010-03-09')
select datename(dd,'2010-10-04')
select datename(mm,'2010-10-04')
select datename(yy,'2010-10-04')
select datepart(dd,'2010-10-04')
select datepart(mm,'2010-10-04')
select datepart(yy,'2010-10-04')
select getutcdate()
select datepart(q,'2010-08-04')
select datepart(dw,'2010-10-04')
select datepart(dw,'2010-10-20')

select sqrt(625)
select sqrt(620)
select sqrt(238904758954127748554474854217)
select pi()
select sign(-23)
select floor(234.456)
select log(10)
select log10(100)
select round(234.456,2)
select rand(23)
select cos(45)
select tan(45)
select degrees(90)
select power(23,4)
select radians(90)
select abs(223)

=>I want to tell you about some ranking function here, it is very useful to retrieve wishing value from the database here i quere on my table Amit Which is created already above 

select  name, rank() over (order by age  desc)as rank from Amit
select name, rank()over(order by age asc)as rank from Amit
select name, rank () over(order by salary asc)as rank from Amit
select name, row_number() over(order by age asc)as rank from Amit
select name, dance_rank() over (order by age asc)as rank from Amit

=>Now i  give you a very important code to fetch the appropriate/ exact value from the database because we always want to see the value of  proper Person record so write code below and select it and press F5 button to run this code.(it has impotant that is is searched by unique Id (int) value data type) 

select *from Amit where sid = '4'

=> Now , i tell you about something Computer feature which is seen by SQL Command, here i give you some Code below select and run it in your sql Page.
select host_Id()
select host_name()
select user_Id()
select suser_Id()
select suser_sid()
select user_name()
select suser_sname()
select db_id()
select db_name()
select @@version

=> Now I want to tell you about schema . it is important and very easy. I tell you already that we can not create same name table in one database. If we want to create the same name table then we have to create schema which help us to create duplicate table in same data base so write code as below and run it before.

 create schema Saxena

=> run this above code  and after that we can create the same name table but schemaname.(. dott)table name as show here saxena.Amit
create table saxena.Amit
Name char(20),
age int,
city char(20)
insert into saxena.amit values('Amit Saxena',20,'Patna')
select*from saxena.amit

=> same coding to see the value with schema name

=>Now  I Want to tell some Important Sql Coding , We always want to see the two table value with One command so Here some SQL provide ' Joint' Command for it. Now I created table as below you can also create your own table but some Column should be same because when we want to see the two comman value then it is must for it show as example

Now  First of all create three tabel as below:-
create table ranjeet
sid char(10),
name char(19),
Address char(30)
insert into ranjeet values('S01','Anupkumar','patna')
insert into ranjeet values('S02','sandee pkumar','paliganj')
insert into ranjeet values('S03','prem kumar','berer')
insert into ranjeet values('S04','suraj kumar','bela')
insert into ranjeet values('S05','sushil kumar','patut')

create table Ajit

Sid char(10),
Fname char(19),
State char(20)
insert into Ajit values('S04','Rupesh kumar','phatepur')
insert into Ajit values('S05','Mantu kumar','goh')
insert into Ajit values('S06','tinku kumar','Madhwa')
insert into Ajit values('S07','muna kumar','Amarpura')
insert into Ajit values('S07','kunadan kumar','Rajapur')

insert into Ajit values('S08','Sonu kumar','Makhmilpur')
insert into Ajit values('S09','Laxmikant kumar','sikandarpur')
create table Sujit
Sid char(10),
Sdname char(20),
District char(20)
insert into Sujit values('S08','Pankaj kumar','Chapra')
insert into Sujit values('S09','Pintu kumar','rajipur')
insert into Sujit values('S010','Ravi kumar','Ara')
insert into Sujit values('S011','Sunny','Danapur')

=>After that creating Table We  will write coding as below to see the value 
there are following command to see different type of command as below take any comma will mistake then it provide error message

select ranjeet1d.Sid,name,fname,address,state from ranjeet ranjeet1d inner join Ajit Ajit1d on ranjeet1d.sid = Ajit1d.sid
select Ajit1d.Sid,fname,sdname,state,District from Ajit Ajit1d inner join Sujit Sujit1d on Ajit1d.sid = Sujit1d.sid
select ranjeet1d.sid,name,fname,Address,state from ranjeet ranjeet1d left outer join Ajit Ajit1d on ranjeet1d.sid = Ajit1d.Sid
select Ajit1d.Sid,fname,sdname,state,District from Ajit Ajit1d left outer join Sujit Sujit1d on Ajit1d.sid = Sujit1d.sid
select ranjeet1d.Sid,name,fname,address,state from ranjeet ranjeet1d Right outer join Ajit Ajit1d on ranjeet1d.sid = Ajit1d.sid
select Ajit1d.Sid,fname,sdname,state,District from Ajit Ajit1d right outer join Sujit Sujit1d on Ajit1d.sid = Sujit1d.sid
select ranjeet1d.Sid,name,fname,address,state from ranjeet ranjeet1d full outer join Ajit Ajit1d on ranjeet1d.sid = Ajit1d.sid
select name, fname,address,state from ranjeet cross join Ajit
select  fname,sdname,state,district from Ajit cross join sujit

select ranjeet1d.sid,ranjeet1s.name  from ranjeet ranjeet1d join ranjeet ranjeet1s on ranjeet1d.sid = ranjeet1s.sid
select Ajit1d.sid,Ajit1s.fname  from Ajit Ajit1d join Ajit Ajit1s on Ajit1d.sid = Ajit1s.sid
select Sujit1d.sid,Sujit1s.sdname  from Sujit Sujit1d join Sujit Sujit1s on Sujit1d.sid = Sujit1s.sid

=> Now am going to discuss the command which is different some way. we always want to see the value which is bigger or smaller than the selected person it is always used in office and other work mostly So write the code as below
we can see here the salary is grater than Rahul sallary so write as here
select *from Amit where salary>(select salary from Amit where name = 'Rahul kumar')
select*from Amit where exist(select*from Amit where name = 'Rahul kumar')

=> select the above line one by one and press F5 button to see the result

=> Now I want to describe the very important command here. It is very important to security reason because we always want to save some special unique information which full fill our rules and regulation so i create such a table which as some special rules for create the desired table
here see below

create table Suman
Sid char(10)constraint dk primary key,     
Name char(16)not null,                              
state char(15)Constraint bk check(state in('Bihar','Up','Mp')),  
RollNo int constraint pk unique,     
dateOf_Entry datetime constraint gh default getdate()      

Primary Key  (it allow only onle value as roll is unique)
Null  ( it not allowed empty column)   
check ( It check the state name if valid the ok. )
Unique (it also define unique value not allowed duplicate data )
default ( it Insert automatic date time so we have not enter)

=> Now Insert the value as following ways

insert into Suman values('S01','Amit kumar','Bihar',1,default)
insert into Suman Values('S02','Anil kumar','Up',2,22-11-2010)
insert into Suman values('S03','Ajit kumar','up',3,default)
insert into Suman values('S04','Alit kumar','Bihar',4,default)
insert into Suman values('S05','Amitabh kumar','Bihar',5,default)
insert into Suman values('S06','Anup kumar','Bihar',6,default)

To see the value as below:
select*from Suman

=> Now I want discuss about foreign key constraint  take care here the table name value and foreign key name too here , it something hart to understan but mention not i clear all here. First of all Create table as below

create table Mamta
Sid char(10)constraint hk foreign key references Suman(Sid),
Name char(23),
State char(24)constraint ck check(State in('Bihar','Karnatak' )),
Age int

select all and run it.pressing F5 key.

Note:- take care , we can insert data as like as suman table . We could Insert the data which is also available in suman table with Sid No. because we create the rules of foreign key which allowed only abobe table value
so take care and and Insert the value which is also available in suman tavle (here in both table sid column must)

insert into Mamta values('S01','Amit kumar','Bihar',23)
insert into Mamta values('S05','Amit kumar','Bihar',23)
insert into Mamta values('S02','Amit kumar','Bihar',23)
insert into Mamta values('S03','Ankit kumar','Bihar',27)
select*from Mamta

Note: Any Problem then you can send me message- and can ask about it.

=> Now I want to describe here some rule on table take care the table name and rules name here we define some rules below

create rule mohan As @City in('bihar','up','mumbai')
 => select all and run the command .

=>Now I am going to bind the rule on my table name amit which created above

sp_bindrule 'Mohan','amit.city'

insert into Amit values(21,'Amit kumar',19,'Bihar', 10000)

Note : Now we can only insert the value in bihar, up and Mumbai in spite of it , no value can be inserted.

if you will want to enter the other state name then it occur error message.

=>Now  Write the  below code to unbind the rule after that we can insert as we wish 


=> Now I want to tell about something  about user defined datatype which helped to write again  and again data type and given value. but take care here that one we define  the datatype then we can not change the value for it. here see the following code and run the command

create type Anup from char(20)     (select it and run this command)
create table Anurag
Name Anup constraint pd primary key,
village Anup  constraint de unique ,
Pstation Anup,
District Anup

Note : Now we need not define char value again and again we only write the defined char name only here Anup

insert into Anurag values('Anita kumari','Amarpura','Paliganj','patna')
insert into Anurag values('Anju kumari','phatepur','Paliganj','Madhepura')
insert into Anurag values('Ankasha kumari','monapura','bokaro','Panjab')
insert into Anurag values('Anumalika kumari','Pario','Paliganj','patna')

select*from Anurag      ( you can select line and run the code)

Very Important => There is a important command to delete the table or it's wishing column only it is very- very important and it is always ask in Interview Question

Drop and delete are two command for it, but a miser difference between  in both.
We clear here both

Delete table amit   ----- it means it is permanently deleted from your database but
 Drop table amit ---- it means it only delete column value not table so
take care it.

=> Now I disscus here about delete the wishing column so write the following code as below

Alter table Anurag drop column District

=> To add the new Column then we have to write the following code as below

Alter table Anurag add city char(20)

=> how to rename the table name write the code as below and run it.
Sp_rename 'Anurag', 'AnupRaj'

Note The table name is changed so we can see the value of table with new name.

select*from AnupRaj

=> To drop the constraint rule then we have to write the code as below

Alter table Anurag drop constraint pd

Alter table Anurag drop constraint de

create table Raju
Sid char (10),
Name char(19),
Village char(20),
District char(20),
MobileNumber varchar(19)
insert into Raju values('S01','Munna Bai','Raphuganj','Donchak','9279022826')

=> We can Insert The Value In Another Way in the table it is also famous and useful for wishing field values. In Which Column we want to insert then only wishing column can be inserted . See the below Coding

insert into Raju (Sid, village)values('S07','Nanital')

Create table Sonu
Name char(20),
Id int Identity,
Addrss char(20),
Mobile varchar(23)

insert into Sonu  values('AnkitRaj', 'Sasaram',9852883149)
insert into Sonu values('AmitRaj', 'Amarpura', 9279022826)
insert into Sonu  values('MantuRaj', 'Sahrasa','9852883149')
insert into Sonu  values('rajkishire', 'Sitapur',9543984325)
select *from Sonu

=> Here I want to tell you about How to update the table values at appropriate column or row so take care this code. It is very useful for future and mostly using code in sql.

update Sonu set Addrss = 'Gitapur'where id =4

select *into Monu from Sonu

select*from monu

=> Now I want to Describe the XML Conversion of SQL Data, It is very Important for software Engineering Sector. We store to data in XML Because it is easy to load data online. It is very useful to Convert data in any format. So let's see how is it possible 
First of all I create here a new table below after that we will write the command below to convert the data so follow the rule below

here I apply on above Table Name Monu

There are three way to see the table in XML Format These are following:-

select*from Monu for xml raw
select *from Monu for xml auto
select*from Monu for xml Path

=> Now I want to tell about How to Create Direct Creating XML Formatting Table in SQL

Create table Mantu

detail xml

=> How To Insert the Value in Direct XML Value see below coding

 insert into Mantu Values('<StudentInfo> <Name> AmitSaxena</Name><age>21</Age><city>Patna</city></StudentInfo>')

=> Here i want to create Index On the table. It is useful for long Values Table
let see here.how to create. Here you can not see effect but if table has huge collection of data then it is very useful for table.here i create index on my above table name amit see the following code

create clustered Index bina on amit(Sid)

=> Create non-clustered index on the table

create nonclustered index riina on amit(Sid)

=> Now I want to tell you about enable index or disable index on the table see below code

Alter index bina on amit disable
Alter index bina on amit rebuild

=> Now I want to tell you about how to rename the index name so see the below coding

exec sp_rename 'amit.bina','tina'

=> Now I want to tell about a unique code that could be able to find out the our wish column value from the table that is called View. So you  Write the following code to see the wishing values from the table.

create view sangita as select Sid ,City, name from amit

=> To See the table content now with view command see below coding

select*from sangita

=> Drop the View Command from the table , write the following code

drop view Sangita

=> Create View with Encryption , it means as some rule on specific column like as sid, that is show in below example

create view soni with encryption as select Sid, name,city from amit
select*from soni

=> Now I want to  describe the view with encryption together schema. see below, first of all create a schema after that we bind the view 

create Schema komal
create view komal.soni with Schemabinding as select Sid, name, city from dbo.amit
select *from komal.Soni
drop view komal.Soni
Create unique Clustered index moni on komal.Soni(Sid)
create unique Clustered index manish on soni(Sid)

=> Now I want to  describe  the rules that search Indirect with sub name

create table riya

Book_Name char (40)primary key,
Book_Id char(20)
insert into riya values('Math by kc sinha','b10010'  )
insert into riya values('phisic by kc sinha','b10011'  )
insert into riya values('hindi by Rc verma','b10012'  )
insert into riya values('English by Dc sinha','b10013'  )
insert into riya values('Chemistry by dk sinha','b10014'  )
insert into riya values('Geology by sc vema','b10015'  )
insert into riya values('Civics by Hc sharma','b10016'  )
insert into riya values('History by Mc sharma','b10017'  )
insert into riya values('Computer by Rc sinha','b10010'  )

select*from riya

=> Now bind the rule over the table see the code below

Sp_fulltext_database enable
create fulltext catalog riya as default
create unique index rabina on riya(Book_Name)
create fulltext index on dbo.riya(Book_Name)key index rabina
select*from riya where freetext(Book_Name,'Sinha')
select*from riya where Contains(Book_Name, 'sinha near kc')

=.> Now I want to describe some function In SQL that follow some rules and regulation

declare @name char(20)
set @name = 'Amitkumar'
print @name

Note : {select all together above code and run it}

I create some other  rules select all and run the code as pressing F5 Key.

declare @name char(24),
@Age int, @City char(15),
@state char(20)
Set @name = 'Amitraj'
set @Age = 23
set @city = 'patna'
set @state = 'bihar'
select @name, @age, @city, @state
(Select all and run it)

=> Now I want to describe the function which check the condition values if valid the message sussess or invalid the error message.

declare @age int
set @age = 19
if (@Age>18)
print 'valid for Voting'
print 'Not valid for voting'

Note :select all above all code and press F5 Button to see the result.

=> I declare some other function below , select it all and press F5 Button to see the result.

declare @num int
set @num = 12
begin print 'welcome darling i love you'
set @num  = @num-1

(Select all and run it)

=>  Now I want to describe the very use ful coding that show if error occur then shown  our defines message so first of all create table and then apply the rules see below coding

create table Monalisha
Sid char(10)primary key,
Name char(20),
city char(20),
State char(20)
insert into Monalisha values('S01','Amit kumar','Patna','Bihar')
insert into Monalisha values('S02','Ankit kumar','lakhnau','Up')
insert into Monalisha values('S03','sunil kumar','jaypur','Raj sthan')
insert into Monalisha values('S04','rajsh kumar','kolkata','Bangal')
insert into Monalisha values('S05','Arun kumar','mangola','Urisha')
insert into Monalisha values('S06','Rupam kumar','kohima','nagaland')
insert into Monalisha values('S07','Amitabh kumar','bangolore','Karnatak')
insert into Monalisha values('S08','Anuj kumar','Mumbai','Mharast')

=> Now Bind the rules write the following code and select all and run it.

begin try
insert into Monalisha values('S02','Sunnykumar','panji','Goa')
end try
begin catch
select 'error is' +error_message()as emessage,
error_line()as eline,
error_number()as enumber,
error_Severity()as eserve,
error_procedure()as epros,
error_state()as estate
end catch

(Select all and run it)

create procedure malika
as begin
select*from Monalisha


create procedure komal @sid
select*from Monalisha where Sid = 'S02'
exec komal 'S02'

create procedure rani
exec malika

drop procedure rani

create function  dbo.Sonam(@val int)
as begin
(Select all an run it)

declare @result int
set @result = dbo.Sonam(19)
print @result
(select and run it)

select*from Mamta
select*from Mantu
select*from Suman
create trigger Aish on Monalisha for insert as print'welcome for inserting data'
Create trigger Amrita on Monalisha for update as print'Mention not darlind as you like.'
Create trigger Ansu on Monalisha for delete as print 'Thankyou for deleting data'
insert into Monalisha values('S014','Munna bhai','patna','Bihar')
update monalisha set Name = 'Mahes verma' where Sid = 'S011'
delete monalisha where Sid = 'S011'
begin tran
insert into Monalisha values('S011','Dhmendra','patna','Bihar')
Commit tran

begin tran
update monalisha set Name = 'Nilesh verma' where Sid = 'S015'
commit tran

begin tran
delete monalisha where Sid = 'S015'
commit tran

select*from monalisha
create table kajol
Sid char(20),
Name char(20),
Salary money
insert into kajol values('So1','Amitkumar',15000)
insert into kajol values('So2','Ankitkumar',16000)
insert into kajol values('So3','Anitkumar',17000)
insert into kajol values('So4','Amrtkumar',18000)
insert into kajol values('So5','Amishkumar',18000)
begin tran
if (Select avg (salary)from kajol)>14000
insert into kajol values('S07','rakeshkumar',58000)
commit tran
Rollback tran
select*from kajol

Now Enjoy this Nice collection Of SQL Command , . thanks a lots to visit my site. You can also see a nice coding of Digital Calculator here.