Login
Register
All Activity
Questions
Unanswered
Tags
Users
Ask a Question
About Us
986
Questions
785
Answers
Interview Preparation mode
beta
Funny Facebook Status
Enter your email address
All categories
SQL Server Interview Questions and Answers
(197)
SSIS Interview Questions and Answers
(54)
SSRS Interview Questions and Answers
(9)
SSAS Interview Questions and Answers
(29)
.NET Interview Questions and Answers
(186)
Oracle Interview Questions and Answers
(122)
Java Interview Questions and Answers
(32)
UNIX Interview Questions and Answers
(47)
Networking Interview Questions and Answers
(17)
MySQL Interview Questions and Answers
(30)
HR Interview Questions and Answers
(237)
General Interview Questions and Answers
(9)
Other Interview Questions and Answers
(8)
Job Openings
(3)
Greenplum Database Interview Questions and Answers
(5)
What is Table Valued Parameter, in MS SQL Server?
Nice?
Vote!
Table-Valued parameters, as the name suggests lets you pass a table as parameter to a stored procedure. In order to use table-valued parameters you need to define a table type and then use the table type in the definition of the stored procedure.
First creating the table type
Create Type Songs_TableType as Table
(Title nvarchar(120) not null,
TrackNumber int)
create procedure AddSongs(
@ArtistName nvarchar(120),
@AlbumName nvarchar(120),
@Songs Songs_TableType READONLY)
as
begin
-- Add the Artist
Declare @ArtistID int
insert into Artists values (@ArtistName)
select @ArtistID = SCOPE_IDENTITY()
-- Add the Album
Declare @AlbumID int
insert into Albums values (@AlbumName, @ArtistID)
select @AlbumID = SCOPE_IDENTITY()
-- Insert songs
insert into Songs
select title, trackNumber, @AlbumID, @ArtistID
from @Songs
end
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
–
edited
1 year
ago
by
R
sql-server-interview-question
table
t-sql
Your answer
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
0 Answers
Related questions
Nice?
Vote!
4
answers
What is Cascade and Restrict in DROP table SQL, in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
t-sql
table
database
Nice?
Vote!
Add
Ans!
What is “CROSS JOIN”, in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
t-sql
table
joins
Nice?
Vote!
1
answer
How to import table using “INSERT” statement, in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
table
t-sql
Nice?
Vote!
1
answer
What is CTE (Common Table Expression), in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
t-sql
Nice?
Vote!
Add
Ans!
Which to Use - Temporary Tables OR Table Variables, in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
table