I created a stored procedure like this
ALTER PROC [dbo].[SP_COMP]
(@comp_seq INT,
@channel VARCHAR(10),
@comp_type VARCHAR(10),
@periode_awal DATETIME,
@periode_akhir DATETIME,
@period_type VARCHAR(20),
@rn_from DATETIME,
@mode int)
and then I execute it:
EXEC [SP_COMP] 16, 'A', '', '2017-07-16', '2017-07-31', 'MONTH_END', '2017-07-01', 6
But I get this error :
Msg 201, Level 16, State 3, Procedure SP_COMP, Line 0
Procedure 'SP_COMP' expects parameter '@rn_from', which was not supplied
Is there something wrong with my procedure?
One problem could be with the prefix SP_ you are using.
see this http://sqlperformance.com/2012/10/t-sql-queries/sp_prefix
and this https://msdn.microsoft.com/en-us/library/ms190669(v=sql.105).aspx
Also try creating datetime variables to pass to the procedure.
Also always use a language neutral format for datetime values, see this article
http://karaszi.com/the-ultimate-guide-to-the-datetime-datatypes
declare @periode_awal DATETIME = '20170716'
declare @periode_akhir DATETIME = '20170731'
declare @rn_from DATETIME = '20170701'
EXEC [dbo].[SP_COMP] 16, 'A', '', @periode_awal, @periode_akhir, 'MONTH_END', @rn_from, 6
I also do not recommend populating your table with '' values, better use null
EDIT
when you alter the procedure and call it in one session, then please add a GO between the 2 statements
ALTER PROC [dbo].[SP_COMP](
@comp_seq INT,
@channel VARCHAR(10),
@comp_type VARCHAR(10),
@periode_awal DATETIME,
@periode_akhir DATETIME,
@period_type VARCHAR(20),
@rn_from DATETIME,
@mode int
)
GO -- always put this after an alter or create statement
declare @periode_awal DATETIME = '20170716'
declare @periode_akhir DATETIME = '20170731'
declare @rn_from DATETIME = '20170701'
EXEC [dbo].[SP_COMP] 16, 'A', '', @periode_awal, @periode_akhir, 'MONTH_END', @rn_from, 6