MS SQL 2008 mendukung TVP: fitur yang berguna untuk mengunggah data massal ke proses tersimpan untuk diproses.
Daripada membuat tipe yang ditentukan pengguna, apakah mungkin untuk meningkatkan definisi tabel yang ada? Misalnya, apakah mungkin membuat proses tersimpan dengan tanda tangan berikut?
CREATE PROCEDURE usp_InsertProductionLocation
@TVP **LocationTable** READONLY
Dokumentasi itu sepertinya menunjukkan bahwa ini tidak mungkin.
KODE SAMPEL
/*
Sample code from:
http://msdn.microsoft.com/en-us/library/bb510489.aspx
*/
USE AdventureWorks2008R2;
GO
/* Create a table type. */
CREATE TYPE LocationTableType AS TABLE
( LocationName VARCHAR(50)
, CostRate INT );
GO
/* Create a procedure to receive data for the table-valued parameter. */
CREATE PROCEDURE usp_InsertProductionLocation
@TVP LocationTableType READONLY
AS
SET NOCOUNT ON
INSERT INTO [AdventureWorks2008R2].[Production].[Location]
([Name]
,[CostRate]
,[Availability]
,[ModifiedDate])
SELECT *, 0, GETDATE()
FROM @TVP;
GO
/* Declare a variable that references the type. */
DECLARE @LocationTVP
AS LocationTableType;
/* Add data to the table variable. */
INSERT INTO @LocationTVP (LocationName, CostRate)
SELECT [Name], 0.00
FROM
[AdventureWorks2008R2].[Person].[StateProvince];
/* Pass the table variable data to a stored procedure. */
EXEC usp_InsertProductionLocation @LocationTVP;
GO
/*
The following is not part of the original source code:
*/
CREATE TABLE LocationTable(
LocationName VARCHAR(50)
, CostRate INT );
GO