Step 1
Creating the Student Table:
- CREATE TABLE Student
- (
- ID INT IDENTITY(1,1) PRIMARY KEY,
- FirstName VARCHAR(50),
- LastName VARCHAR(50),
- Marks INT
- )
Step 2
Inserting the some sample data:
- INSERT INTO Student (FirstName,LastName,Marks) VALUES('rakesh','kalluri',500)
- INSERT INTO Student (FirstName,LastName,Marks) VALUES('Ali','MD',600)
- INSERT INTO Student (FirstName,LastName,Marks) VALUES('Raju','Ganga',700)
Step 3
Create procedure with out parameters:
- CREATE PROCEDURE Get_StudentInformation
- AS
- BEGIN
- SELECT * FROM Student
- END
Step 4
Create Student table in Tempdb:
- CREATE TABLE Tempdb.#Student
- (
- ID INT ,
- FirstName VARCHAR(50),
- LastName VARCHAR(50),
- Marks INT
- )
Step 5
Inserting data from stored procedure to Temp Table:
- INSERT INTO Tempdb.#Student
- EXEC Get_StudentInformation
Step 6
Select data from Temp Table:
- SELECT * FROM Tempdb.#Student
Step 7
Truncating Temp Table:
- TRUNCATE TABLE Tempdb.#Student
Step 8
Create procedure with parameters:
- CREATE PROCEDURE Get_StudentInformationWithID
- (@In_ID int)
- AS
- BEGIN
- SELECT * FROM Student where ID= @In_ID
- END
Step 9
Inserting data from stored procedure with parameter to Temp Table:
- INSERT INTO Tempdb.#Student
- EXEC Get_StudentInformationWithID 1
Step 10
Select data from Temp Table:
- SELECT * FROM Tempdb.#Student
Step 11
Drop Temp Table:
- DROP TABLE Tempdb.#Student