For a reason unknown to me, I cannot access the contents of my TVP. The debugger says @_AccountList and @AccountTVP are tables, but I cannot view the contents, print them, nor will intellisense offer me auto completion for a column. I feel like probably declared something wrong or have an ambiguous definition. Any suggestions?
CREATE TYPE AccountList
AS TABLE
(
AccountNumber varchar(50),
AccountType varchar(50)
)
GO
CREATE PROCEDURE [dbo].[updateNumbers_ArchiveDB]
@_AccountList AccountList READONLY,
@padding int,
@proc_dateStart datetime,
@proc_dateEnd datetime
AS
DECLARE @AccountTVP AS AccountList;
BEGIN
SET NOCOUNT ON;
SELECT * FROM @AccountTVP;
UPDATE dbo.Archive2007001
SET LogicalAccount = @padding + AccountNumber
FROM dbo.Archive2007001 INNER JOIN @AccountTVP AS tvp
ON dbo.Archive2007001.LogicalAccount = tvp.AccountNumber
WHERE ProcessDate BETWEEN @proc_dateStart AND @proc_dateEnd
UPDATE dbo.DailyArchive
SET LogicalAccount = @padding + AccountNumber
FROM dbo.DailyArchive INNER JOIN @AccountTVP AS tvp
ON dbo.DailyArchive.LogicalAccount = tvp.AccountNumber
WHERE ProcessDate BETWEEN @proc_dateStart AND @proc_dateEnd
-- does not work PRINT N'tvp.AccountNumber is ' + @AccountTVP.AccountNumber
END
Here is how I am executing the procedure.
declare @p1 dbo.AccountList
insert into @p1 values(N'Account Number',N'Account Type')
insert into @p1 values(N'7463689',N'Basic')
insert into @p1 values(N'1317893',N'Premium')
insert into @p1 values(N'2806127',N'Basic')
exec updateNumbers_ArchiveDB
@_AccountList=@p1,
@padding=N'111',
@proc_dateStart='2008-01-04 11:24:46',
@proc_dateEnd='2008-01-04 11:24:46'
Answer: The data I was looking for was loaded in @_AccountList
, not @AccountTVP
.