I want to create a stored procedure with the following parameter: @WorkspaceID int
What I have now is this:
DECLARE @WorkspaceRuleIds varchar(max)
SELECT @WorkspaceRuleIds = COALESCE(@WorkspaceRuleIds + ', ', '') +
CAST(RuleID AS varchar(5))
FROM Dgn_Workspace_Rules
WHERE WorkspaceID = @WorkspaceID;
SELECT ag.*
FROM Dgn_Rules ag
LEFT JOIN Dgn_Workspace_Rules wr ON ag.RuleID IN (@WorkspaceRuleIds)
WHERE wr.WorkspaceID = @WorkspaceID
If @WorkspaceID receives value of 25 then ag.RuleID IN (80,82) should get as parameters... but I get this error instead
Msg 245, Level 16, State 1, Line 3
Conversion failed when converting the nvarchar value '80,82' to data type int.
How do I fix this? Thanks!
mysql. Which is it?SELECTwith a join ofag.RuleID = wr.RuleID? I can't see why you're trying to mangle these rule IDs into a string just to then turn around and have problems with trying to pull the values back out of that string.