Hi everybody,
I have the following C# code to execute stored procedure in Entity Framework:
SqlParameter originalContact = new SqlParameter("@originalContact", SqlDbType.Decimal, 17);
originalContact.Value = idToRemove;
SqlParameter newContact = new SqlParameter("@newContact", SqlDbType.Decimal, 17);
newContact.Value = idToKeep;
SqlParameter Salespoint = new SqlParameter("@salespoint", SqlDbType.Char, 6);
Salespoint.Value = salespoint;
SqlParameter opCode = new SqlParameter("@operator", SqlDbType.Char, 6);
opCode.Value = operatorCode;
SqlParameter debug = new SqlParameter("@debug", SqlDbType.Bit);
debug.Value = 0;
_siriusContext.CoreContext.ExecuteStoreCommand(@"execute dbo.siriussp_DedupeContact
@originalContact = @originalContact,
@newContact = @newContact,
@salespoint = @salespoint,
@operator = @operator,
@debug = @debug", originalContact, newContact, Salespoint, opCode, debug);
The stored procedure has parameters defined as decimal(17,0) - matching the column's type in the table, e.g.
ALTER PROCEDURE dbo.siriussp_DedupeContact
(@originalContact decimal(17,0),
@newContact decimal(17,0),
@salespoint CHAR(6),
@operator CHAR(6),
@debug bit = 1)
However, when I check the call using SQL Server Profiler I see
exec sp_executesql N'execute dbo.siriussp_DedupeContact
@originalContact = @originalContact,
@newContact = @newContact,
@salespoint = @salespoint,
@operator = @operator,
@debug = @debug',N'@originalContact decimal(9,0),
@newContact decimal(9,0),@salespoint char(6),@operator char(6),@debug bit',
@originalContact=167000001,@newContact=129000001,@salespoint='SYSMGR',@operator='ADMIN ',@debug=0
It is probably not critical, but why the explicitly stated size of the parameter is ignored in the call?
UPDATE. I'm going to try without @par=@par, just with @par syntax now.
UPDATE 2. Changing the call syntax to remove the = part didn't change anything. The size is still ignored.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles