Suppose that I have a two column User Defined Table type
CREATE TYPE [Schema].[Type] AS TABLE (
[Name] NVARCHAR (100) NULL
[Value] int NULL
);
Further suppose that I have stored procedure that I pass the table type to
CREATE PROCEDURE [Schema].[sp_SomeProcedure]
@TVP [Type] READONLY
AS
SELECT
[Name]
,1 + [Value]
FROM
@TVP
Can I default the value of @TVP to be
(SELECT 'John', 1)
You can use the 'DEFAULT' keyword for the TVP when calling the procedure. That will pass an empty table of the type.
Example - if the TVP is the second parameter passed to a procedure:
Exec myProcedure (intParam, DEFAULT)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With