I have used stored procedure with parameters to generate the result set for my report in reporting services 2012 but the result returned is wrong. I traced the command generated and here it is:
EXEC sp_executesql N'EXECUTE [Controls&Compliance].[dbo].[GetAccountsDetails_2]'
,N'@Region nvarchar(4000),@Market nvarchar(4000),@SiteID nvarchar(4000),@ServerClass nvarchar(4000),@InstanceName nvarchar(4000),@LoginName nvarchar(8)'
,@Region = NULL
,@Market = NULL
,@SiteID = NULL
,@ServerClass = NULL
,@InstanceName = NULL
,@LoginName = N'1C_admin'
This command generate thousand of rows.
The strange thing is that if I execute the code outside the sp_executesql
it return the correct result (1 row):
EXECUTE [Controls&Compliance].[dbo].[GetAccountsDetails_2] @Region = NULL
,@Market = NULL
,@SiteID = NULL
,@ServerClass = NULL
,@InstanceName = NULL
,@LoginName = N'1C_admin'
I have read an article about problem generated by the wrong parameter order, but this is not the case. I also checked for the parameter data type and all are the same type.
Could someone help to understand why this behaviour and how to avoid it?