Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error:-Procedure or function 'spAddVoucherCheck' expects parameter '@CreatedAt', which was not supplied.

My store-p Name spAddVoucherCheck

SQL
ALTER PROC [dbo].[spAddVoucherCheck]
 @xml xml,
@CreatedAt Varchar(200), @AccessBy int,
@error varchar(1000) output
AS
BEGIN
BEGIN TRY
DECLARE @MAXID as int;
SELECT @MAXID = ISNULL(MAX(ID), 0) FROM VoucherCheck;
INSERT INTO VoucherCheck(Title , CreatedAt ,CreatedOn,UpdatedOn,Status,CreatedBy,UpdatedBy,IPAddress
)
SELECT N.value('(Title)[1]', 'Varchar(MAX)') ,@CreatedAt,getdate(),getdate(),N.value('(Status)[1]', 'bit'),N.value('(CreatedBy)[1]', 'int'),N.value('(UpdatedBy)[1]', 'int'),N.value('(IPAddress)[1]', 'Varchar(50)') FROM @XML.nodes('/Table/VoucherCheck') as T(N);
DECLARE @SQL as Varchar(2000);
INSERT INTO VoucherCheckAccess (AccessAt, DataID, AccessBy)
SELECT @CreatedAt, T1.ID, @AccessBy FROM VoucherCheck T1 WHERE T1.ID > @MaxID;
END TRY
BEGIN CATCH
SET @Error = ERROR_NUMBER() + ' ' + ERROR_MESSAGE();
END CATCH
END
Posted
Updated 7-Nov-14 20:37pm
v2
Comments
Garth J Lancaster 8-Nov-14 2:40am    
do you get that error on the 'alter' shown above, or when you try and use that stored proc ? if its when you try and use 'spAddVoucherCheck', please supply the code snippet around where you call/invoke the stored proc

1 solution

@CreatedAt is an input parameter to your SP, so when you call it you have to provide the data to fill it. The error doesn't occur when you creta ethe SP, it happens when you call it. So try:
SQL
EXEC dbo.spAddVoucherCheck @CreatedAt='Hello', ...


BTW: the name @CreatedAt implies this is date based data: if so then don't store it as NVARCHAR - use a DATETIME field instead - it makes everything you do with the data later a lot, lot easier. As a result, the @CreatedAt parameter to your SP should be DATETIME as well.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900