Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql stored procedure with table parameter

CREATE PROC usp_PassTable
    @Keys KeyTable READONLY
AS
BEGIN
    SET NOCOUNT ON
    SELECT * FROM @Keys
END
GO
Comment

hot to pass a table valued parameter to a stored procedure in sql server

//To pass a valued parameter to a stored procedure you first need to create a 
//user defined table type.

CREATE TYPE TempTable AS TABLE
(
	INT SubjectID,
  	VARCHAR(50)
);

//Declare a parameter to pass on a stored procedure.
DECLARE @TempTable AS TempTable;
 
 //Insert into a declared value before passing it to a stored proc. 
INSERT INTO @TempTable
VALUES( 1, 'Math'),
	  ( 2, 'Science'),
      ( 3, 'Geometry');    

//Pass the variable to the stored procedure.
EXECUTE Usp_InsertLesson @TempTable;
Comment

PREVIOUS NEXT
Code Example
Sql :: sqlalchemy bulk delete 
Sql :: mysql create table index 
Sql :: mysql workbench tutorial 
Sql :: add week ending date sql server 
Sql :: postgresql database url 
Sql :: add foreign key to existing table 
Sql :: create foreign key postgres 
Sql :: oracle error compilation line 
Sql :: sql unique constraint 
Sql :: from . import _mysql ImportError: libmariadb.so.3: cannot open shared object file: No such file or directory linux 
Sql :: mysql group concat 
Sql :: call function in query sql server 
Sql :: how to force truncate a table in mysql 
Sql :: mysql updating multiple column values from array variable 
Sql :: initcap in sql 
Sql :: postgresql héritage 
Sql :: sql distinct 
Sql :: best sql collation 
Sql :: mysql server not running 
Sql :: how to find max and min salary in sql 
Sql :: how to recreate postgres database in docker 
Sql :: distinct in sql 
Sql :: sql if function 
Sql :: select only distinct values from another table and excluding from current table 
Sql :: sql drop all tables 
Sql :: if sql 
Sql :: last 2 mins sql server 
Sql :: intersect sql 
Sql :: sqlcmd no headers 
Sql :: sql cte example 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =