March 24, 2007 at 12:08 pm
SQL Server 2005 is giving me a headache when I try to create a stored procedure with an input parameter for text values. I am trying to create the following stored procedure which needs to be passed a string of ID numbers:
CREATE PROCEDURE [dbo].[sp_FundingsCount]
(@strApplicationIDs nvarchar(4000) = '',
@intCount
INT OUTPUT)
AS
SET @intCount = (SELECT COUNT(*) AS RecordCount
FROM Fundings
WHERE ApplicationID IN (@strApplicationIDs));
RETURN
@intCount
SQL Server 2005 insists on trying to convert my input parameter to an INT data type:
Syntax error converting the nvarchar value '2038,57' to a column of data type int.
March 24, 2007 at 11:35 pm
WHERE ','+@strApplicationIDs+',' LIKE '%,'+CAST(ApplicationID AS VARCHAR(10)+',%'
Index usage is certainly not possible using this method...
--Jeff Moden
Change is inevitable... Change for the better is not.
March 25, 2007 at 8:12 am
Thanks! I solved the problem by including the subquery in my stored procedures rather than trying to pass them a string of ID numbers.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply