User-Defined Table Types
CREATE TYPE [dbo].[PaymentTableType] AS TABLE(
[Id] [BIGINT] NOT NULL,
[Col01] [VARCHAR](12) NULL,
[Col02] [DATE] NULL,
[Col03] [SMALLMONEY] NULL,
[Col04] [VARCHAR](15) NOT NULL
)
Stored Procedure
CREATE PROCEDURE [dbo].[uspProcessRecords]
@tbRecords dbo.PaymentTableType readonly
AS
BEGIN
END
Code
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetStoredProcCommand("uspProcessRecords");
dbCommand.Parameters.Add(new SqlParameter("@tbRecords", dtRecords));
SqlParameter returnParam = new SqlParameter("@retValue", SqlDbType.Int) { Direction = ParameterDirection.ReturnValue };
dbCommand.Parameters.Add(returnParam);
db.ExecuteNonQuery(dbCommand);
Note: Need to make sure the type type has the right access permissions.
GRANT REFERENCES, EXECUTE ON TYPE::dbo.PaymentTableType TO MyRole
GO
Comments