SQL
SQL Server Stored Procedure
The following product table is used to explain the concept:
ProductID | ProductName | Color | Price |
---|---|---|---|
1 | Bicycle | Red | 1000 |
2 | Motorbike | Blue | 10000 |
3 | Car | Green | 20000 |
4 | Computer | Black | 20000 |
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