sql - Passing a list into a stored procedure -


I have two lists of IDs that need to be inserted into the database. What I want to do here is to take these two lists into a stored procedure and try to add it to the loop for a while. I tried to use the user defined type to define the array, but how to pass it in the order of inserting it

  create [dbo]. [Array] AS TABLE [[Item] [NVARCHAR] (max) NULL);  

This is SQL / PL:

  Optional process [DBO]. Get started as [Sp_create_order] (@Eray Descriptive as Product ID, @ Press IDs, ARA Radonly) @ AINTLARA NAI set @n = count (@productsIdets) set @i = 1; Enter (@ and & lt; = @ n) BEGIN_USDATE (product_id, price_id) prices (@product items [i], @ price eds [i]); Set @i = @i + 1; Eid and Return 0  

Consider changing your type to include both pairs .

 Type  [DBO]. [Producer] AS Tables ([Product Edi] [NVRAR] (MX) Nail, [Price ID] [NVRAR] (Max) Nouvel);  

Then change your process to:

  create process [dbo]. Enter [sp_create_order] @productprices dbo.ProductPrices READONLY in order_detail PproductId, ppriceId @productprices p end  

Then you can call your process like this.

  declare @productprices dbo.ProductPrices; Enter @productprice values ​​('1', '7'), ('2', '12'), ('3', '8'); Exec dbo.sp_create_order @productprices;  

Comments