SQL

SQL Server Stored Procedure

The following product table is used to explain the concept:

ProductIDProductNameColorPrice
1BicycleRed1000
2MotorbikeBlue10000
3CarGreen20000
4ComputerBlack20000

Create Stored procedure:

Create Proc p1
As
SELECT ProductID FROM Product
Return


Execute Stored Procedure:
Exec p1

Output:

1

2

3

4

Data Manipulation Language Commads: Insert, Update, Delete

Insert into Student Values(1,’SQL’,99)
Go
Insert into Student(StudID, Sub) Values(1,’SQL’)
Go
Update Student Set Marks=100 Where StudID=1
Go
Update Student Set Sub=’Maths’, Marks=100 Where StudID=1
Go
Delete from Student1 Where StudID=1

Data Query Language Command: Select
Go
Select * from Student
Go
Select StudID,Sub from Student
Go
Select * from Student where StudID=1
Go
Select * into Student1 from Student
Go
Select * from Student1