开发者

Execute stored procedure with table values as parameter

开发者 https://www.devze.com 2023-04-01 09:14 出处:网络
I create own table type CREATE TYPE [dbo].[ObjectsList] AS TABLE( [Id] [int] NOT N开发者_如何学CULL,

I create own table type

CREATE TYPE [dbo].[ObjectsList] AS TABLE(
[Id] [int] NOT N开发者_如何学CULL,
PRIMARY KEY CLUSTERED 
(
   [Id] ASC
)WITH (IGNORE_DUP_KEY = OFF)
)
GO

and when I want to pass this Type as parameter like

CREATE PROCEDURE [dbo].[GetData](@DataIds ObjectsList READONLY)

how should I pass it in EXEC GetData ????


Look at this

You can find an example

DECLARE @data ObjectList
INSERT @data (Id) VALUES (1)
EXEC GetData @data


To populate @data by using a SELECT statement:

DECLARE @data ObjectList

INSERT @data (Id)
SELECT
  Id
FROM
  <someDB>.<someSchema>.<someTable>
  JOIN ... etc 
WHERE
  ... etc

EXEC GetData @data
0

精彩评论

暂无评论...
验证码 换一张
取 消