Here\'s an example of how to use table-valued parameters in a SQL Server 2008 stored procedure using .NET.
And here\'s the list of parameter types in CF9.
Q
Not sure.
If you need to pass a table of information, probably your best bet is to use the XML data type.
Code sample here.
Short Answer: No support, it should, vote for it!
Long Answer: Coldfusion can use JDBC, which does not yet support TVP's, but it should. Vote for the feature here: http://mssqlconn.uservoice.com/forums/113295-feature-feedback/suggestions/2269687-table-valued-parameters-tvp-support-in-jdbc
XML will work, but using TVP's makes both the client and sproc code easier to read, write, review, and debug. It is also faster in most cases depending on the API's implementation.
FYI, using Oracle is no better. They have the ARRAY SQL data type (which is closest to TVP). It is also not supported by JDBC: Using Array Objects
I discovered this workaround. You can call a stored procedure from within a cfquery, this way you can pass in a Table valued parameter TVP.
<cfquery datasource="" name="">
DECLARE @return_value int
-- Create table value parameter
DECLARE @DataTVP tDataTable;
--Build Table
INSERT INTO @DataTVP(DataId)
VALUES (1),(2),(3)
EXEC @return_value = P_DeleteItems
@tvpData = @DataTVP --Pass table into Stored Procedure
SELECT 'Return Value' = @return_value
</cfquery>
I think the same you need XML Data Type to do so. I am providing an example over here. ##
-- Create a Database
CREATE DATABASE DataTableTest
USE DataTableTest
GO
--Create the sample tables
CREATE TABLE Employees (
EmployeeID BIGINT IDENTITY(1,1),
EmployeeName VARCHAR(50),
DepartmentID BIGINT )
CREATE TABLE Departments (
DepartmentID BIGINT IDENTITY(1,1),
DepartmentName VARCHAR(50) )
GO
-- Populate the Sample Tables
INSERT INTO Departments ( DepartmentName)
SELECT 'IT'
INSERT INTO Employees (EmployeeName, DepartmentID )
SELECT 'JCB', 1
GO
Now let us create a stored procedure which returns two result sets.
CREATE PROCEDURE GetEmployeeInfo
AS
SET NOCOUNT ON
SELECT EmployeeName, DepartmentID
FROM Employees
WHERE EmployeeID = 1
SELECT DepartmentName FROM Departments
WHERE DepartmentID = 1
GO
Let us create the next stored procedure which accepts an XML parameter. This procedure will insert the data from the XML parameter, into the Employee Table.
CREATE PROCEDURE ProcessXml
(
@data XML
)
AS
INSERT INTO Employees(EmployeeName, DepartmentID)
SELECT
x.d.value('EmployeeName[1]','VARCHAR(50)') AS EmployeeName,
x.d.value('DepartmentID[1]','INT') AS DepartmentID
FROM @data.nodes('/NewDataSet/Table') x(d)
GO