Pass tables to Stored Procedures as input

Professionaluser
Posted by Professionaluser under Sql Server category on | Points: 40 | Views : 140
For suppose we have a UDT named as StudentType with columns StudID, StudName and StudFee

CREATE TYPE dbo.StudentType AS TABLE
(
[StudID] [int] ,
[StudName] [varchar](30) ,
[StudFee] [int]
)


How do we pass the above UDT as input to SP?
CREATE PROCEDURE dbo.usp_StudentDetails
@StudentDetail dbo.StudentType READONLY
AS
BEGIN
SET NOCOUNT ON
INSERT INTO dbo.[Student] ([StudentID], [StudentName], [StudentFee])
SELECT [StudID], [StudName], [StudFee] FROM @StudentDetail
END

Comments or Responses

Login to post response