|
Robert, to use the
char string in an SQL IN clause most people would say just use dynamic SQL
(EXEC ...). However, I would never recommend anyone to use dynamic SQL unless it
was an usual circumstance. Instead, I use a UDF called ListToTable which
converts a varchar list to a table variable (not a temp table!) with rows.
Therefore you can write code like so:
DECLARE @myIDString
varchar(100)
SET @myIDString =
'2,3,4,5,6,7,8'
SELECT
*
FROM
entCustomers
WHERE CustID IN
(select ID from dbo.ListToTable(@myIDString) )
Does that make
sense? If you want the code for the UDF let me know.
Daniel
Elmore
-----Original
Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Robert Shaw Sent: Friday, January 28, 2005 10:25 AM To: [email protected] Subject: SQL IN Statement
|
- SQL IN Statement Robert Shaw
- Re: SQL IN Statement Daniel Elmore
- Re: SQL IN Statement Robert Shaw
- RE: SQL IN Statement Daniel Elmore
- Re: SQL IN Statement Robert Shaw
- Re: SQL IN Statement Marlon Moyer
