Thanks Neil for your help. 

-----Original Message-----
From: Robertson-Ravo, Neil (RX)
[mailto:[EMAIL PROTECTED]
Sent: Thursday, January 27, 2005 10:01 AM
To: CF-Community
Subject: RE: SQL Brain Fart


Yes, it is one way.  You could also pass the values into a temp table and
perform a normal select on that temp table with the column (ID) in the where
clause.

Either way will work and both ways are good.

Though by using the latter would result in (probably) better performance as
its no conducting dynamic SQL statements which cannot be precompiled by SQL
Server.





-----Original Message-----
From: John Stanley [mailto:[EMAIL PROTECTED] 
Sent: 27 January 2005 14:59
To: CF-Community
Subject: SQL Brain Fart

100 of your favorite muffins warmed and slathered with Plugra
http://www.kellerscreamery.com/products/plugra/index.php to the first
correct answer.


what's up with this:

declare @list varchar(25)
set @list = '184203,184204'

select * from my_table where id in (@list)

say this list is passed into a proc. i cant figuire out the correct syntax
to return the data without using the method below. 

the id column is an int data type.

i can do this in dynamic sql like.

declare @sql varchar(100), @list varchar(25)
set @list = '184203,184204'

select @sql = 'select * from my_table where id in (' + @list + ')'

exec (@sql)


is the dynamic sql the only way to do this?






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:5:144895
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to