this is my stored procedure:
ALTER PROCEDURE [dbo].[sp_Update_Projecttijden]
@tabelnaam NVARCHAR(30) ,
@starttijd DATETIME,
@eindtijd DATETIME,
@tijd FLOAT,
@startid INT,
@eindid INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
-- DECLARE @DATEVARCHAR NVARCHAR(4000);
DECLARE @SQLCommand NVARCHAR(MAX) = N'
UPDATE ' + QUOTENAME(@tabelnaam) + N'
SET Start = @starttijd
, Einde = @eindtijd
, Tijd = @tijd
, StartID = @startid
, EindID = @eindid
WHERE StartID = @startid AND EindID=@eindid';
EXECUTE dbo.sp_executesql @sqlCommand,
' N @starttijd DATETIME, @eindtijd DATETIME, @tijd FLOAT, @startid INT, @eindid INT'
, @starttijd
, @eindtijd
, @tijd
, @startid
, @eindid;
END
The error thrown is this:
Msg 214, Level 16, State 3, Procedure sp_executesql, Line 3 Procedure expects parameter '@params' of type 'ntext/nchar/nvarchar'.
I have been looking at similar questions/answers, but could not really solve my problem. All help is very much appreciated.
Issue is typo in your code. Notice that your N
is in your string, not before it.N
before string identifies that following text is going to be in unicode, your error actually tells that your procedure expects unicode parameter and gets VARCHAR
instead.
EXECUTE sys.sp_executesql @sqlCommand
, N'@starttijd DATETIME, @eindtijd DATETIME, @tijd FLOAT, @startid INT, @eindid INT'
, @starttijd
, @eindtijd
, @tijd
, @startid
, @eindid;
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