Ste*_*ven 8 sql-server stored-procedures user-defined-types sql-server-2008-r2
我有一个用户定义表,我从存储过程中传递到存储过程.
DECLARE @tmpInput MyTableType;
--Table is populated from an INPUT XML
exec ValidateInputXML SELECT * FROM @tmpInput TI WHERE TI.EntryType = 'Attribute';
Run Code Online (Sandbox Code Playgroud)
现在这不会给我一个错误,但是当我使用ValidateInputXML运行select时,表没有数据.
ven*_*mit 18
您还可以将Table-Valued参数用于存储过程.例如
/* Create a table type. */
CREATE TYPE MyTableType AS TABLE
( Column1 VARCHAR(50)
, ........ );
GO
/* Create a procedure to receive data for the table-valued parameter. */
CREATE PROCEDURE dbo. ValidateInputXML
@TVP MyTableType READONLY
AS
-- Do what ever you want to do with the table received from caller
GO
/* Declare a variable that references the type. */
DECLARE @myTable AS MyTableType;
-- Fill @myTable with data and send it to SP.
insert into @myTable SELECT * FROM @tmpInput TI WHERE TI.EntryType = 'Attribute';
/* Pass the table variable data to a stored procedure. */
EXEC ValidateInputXML @myTable ;
GO
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16638 次 |
最近记录: |