Eh, sorry. I've just found the solution to my own problem.
Just for future reference, this is my solution.
DECLARE @idList varchar(max)
DECLARE @sql varchar(max)
SET @idList = '1,2'
SET @sql = 'SELECT * FROM table WHERE ID IN (' + @idList + ')'
EXEC(@sql)
Thanks
Paul
From: Paul Alkema [mailto:[email protected]]
Sent: Tuesday, April 20, 2010 1:55 PM
To: '[email protected]'
Subject: MSSQL "Where In" not working with variables
I know this is a CF list, sorry for posting this in the wrong area, but I
thought maybe one intelligent people might know. I've been working with the
"WHERE IN" clause in MSQL and It seems not to be working well for me with a
variable for some reason..
This is an example of what I'm trying to do
DECLARE @idList varchar(max)
SET @idList = '1,2'
SELECT *
FROM table
WHERE ID IN (@idList)
Any ideas?
Thanks,
Paul
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333044
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm