best practive to pass multiple table to stored procedure in sql server

Solutions on MaxInterview for best practive to pass multiple table to stored procedure in sql server by the best coders in the world

showing results for - "best practive to pass multiple table to stored procedure in sql server"
Nick
28 Jan 2016
1DECLARE @primaryTVP primary_tbltype
2DECLARE @relatedTVP related_tbltype
3
4INSERT INTO @primaryTVP values (1, 'John', 'Cleese')
5INSERT INTO @primaryTVP values (2, 'Eric', 'Idle')
6INSERT INTO @primaryTVP values (3, 'Graham', 'Chapman')
7
8INSERT INTO @relatedTVP values (1, '29310918', 28934.33)
9INSERT INTO @relatedTVP values (2, '123123', 3418.11)
10INSERT INTO @relatedTVP values (2, '33333', 666.66)
11INSERT INTO @relatedTVP values (3, '554433', 22.22)
12INSERT INTO @relatedTVP values (3, '239482', 151515.15)
13
14
15EXEC MySproc @primaryTVP, @relatedTVP;
Leonie
16 Jan 2017
1CREATE PROCEDURE MySproc
2    @PrimaryTable primary_tbltype READONLY,
3    @RelatedTable related_tbltype READONLY
4AS
5BEGIN
6DECLARE @CurrentKey INT
7DECLARE @FirstName VARCHAR(30)
8DECLARE @LastName VARCHAR(30)
9DECLARE @AccountTotal MONEY
10
11DECLARE PersonCursor CURSOR LOCAL FAST_FORWARD FOR
12    SELECT personkey, firstname, lastname FROM @PrimaryTable
13OPEN PersonCursor
14FETCH NEXT FROM PersonCursor INTO @CurrentKey, @FirstName, @LastName
15WHILE @@FETCH_STATUS= 0 BEGIN
16
17    SELECT @AccountTotal = SUM(accountbalance) FROM @RelatedTable 
18        WHERE fk_personkey = @CurrentKey
19
20    PRINT @FirstName + ' ' + @LastName + ' - account total: ' + CONVERT(VARCHAR(30), @AccountTotal)
21
22    FETCH NEXT FROM PersonCursor INTO @CurrentKey, @FirstName, @LastName
23END
24END;
queries leading to this page
pass table from c 23 to mysql stored procedurepass sql builder in table as parameterstored procedure to insert datatable values into sql tablesql table as parameterstored procedure datatable parameterhow to pass table column as a parameter in stored procedurehow to pass user defned datatale type c 23table valued parameter in sqlpassing table variable as a parameter in sql serverhow to table in input pass parametertable as parameter in stored proceduresql server pass temp table to stored procedureuser defined table type in sql server stored procedurehow test a procedure that takes table argumentsql server stored procedure pass table as parametersql server pass output table variable into stored procedurepass dataset to stored procedure c 23 for insert recordssql server table as parameter to stored proceduresql server istored procedure pass table parameterexecute sp sql server with parameters from data tablepass table variable to stored procedurehow to use table type in stored procedurecreate stored procedure with table type parametertable parameters sqluse of table type parameter is spsql server pass table variable into stored procedure without readonlyhow to pass a structure as parameter in a sphow to pass value from one table to another table in single stored procedurehow to pass table ato stored procedure in sql servers parametertable parameters in sqlhow to capture sql server return value from stored proceduresql server procedure pass parameterexecute stored procedure multiple time sql tabel valued parametsexecute stored procedure with table type parameter in sql serverpassing table records as parameters to bq procedurein valued table procedurespass table to stored procedure sqlc 23 pass stored procedure parameter and read tablehow to insert data into user defined table type in sql serversql table as parameter stored procedurehow to pass values from a table to procedure as parameters pl 2fsqlsend a table through stored procedure parameterc 23 pass user defined table type to stored proceduresql server pass table to stored proceduretable variable as parameter in stored proceduresql execute stored procedure table type parameterstored procedure call with table type parameter 28s 29how to pass table type to procedure in oracle in c 23table valued parameter sql serverusing table variable to pass input to spwhat is local temporary table in oraclehow to insert data as param into sqlsql server send table data as parametersql server procedure that takes tabe argumenthow to insert values in sql table from custom table typetable as a parameter to stored procedurepassing table value to sp sqlhow to pass two parameter in sp with sqlparameter datatablesql server pass table variable to stored procedurecreate procedure to insert data in sql by passing valueshow to pass a table as a parameter in sqlhow to pass table to stored procedure in my sqlhow to insert into a table passed by parameter sqluse table in procedure as parameterudt in stored procedure sqltable input sql proceduresql server table variable parameter stored procedurehow to create procedure in sql and pass value as parameterhow to pass table as parameter in stored procedurepass table to procedure sqlpass table in stored procedureuser defined table in the stored proceduresql pass table as parameter for queryhow to pass table type parameter in c 23 using oracle stored procedureuse type in stored procedure sql serverbest practive to pass multiple table to stored procedure in sql server