--Creating
the Student Table
CREATE
TABLE
Student
(
ID
INT
IDENTITY(1,1)
PRIMARY
KEY,
FirstName
VARCHAR(50),
LastName
VARCHAR(50),
Marks
INT
)
--Inerting
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)
--create
procedure with out parameters
CREATE
PROCEDURE
Get_StudentInformation
AS
BEGIN
SELECT
*
FROM
Student
END
--create
Student table in Tempdb
CREATE
TABLE
Tempdb.#Student
(
ID
INT
,
FirstName
VARCHAR(50),
LastName
VARCHAR(50),
Marks
INT
)
--Inserting
data from stored procedure to Temp Table
INSERT
INTO
Tempdb.#Student
EXEC
Get_StudentInformation
--
select data from Temp Table
SELECT
*
FROM
Tempdb.#Student
--
Trucating Temp Table
TRUNCATE
TABLE
Tempdb.#Student
--
create procedure with parameters
CREATE
PROCEDURE
Get_StudentInformationWithID
(@In_ID
int)
AS
BEGIN
SELECT
*
FROM
Student where
ID=
@In_ID
END
--Inserting
data from stored procedure with parameter to Temp Table
INSERT
INTO
Tempdb.#Student
EXEC
Get_StudentInformationWithID
1
--
select data from Temp Table
SELECT
*
FROM
Tempdb.#Student
--
Drop Temp Table
DROP
TABLE
Tempdb.#Student
hi
ReplyDelete