Try an exec statement.
CREATE PROCEDURE [Search_RC]  @where varchar(255)
AS
exec ('SELECT  count (*) as noofrecords
FROM NPO_IRS_primary '+@where)

-----Original Message-----
From: Mark W. Breneman [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 09, 2000 1:09 PM
To: CF-Talk
Subject: You are a stored Proc god if you can answer this...


I need to do a record count with a CF generated "WHERE" statement.

SELECT  count (*) as noofrecords
FROM xxx
#PreserveSingleQuotes(searchstring)#

Now I need to convert this into a stored proc.

I tried:
CREATE PROCEDURE [Search_RC]  @where varchar(255)
AS

SELECT  count (*) as noofrecords
FROM NPO_IRS_primary
@where

No luck...

Any one have an idea?



Example of the "WHERE" statement:
WHERE (State = 'NC') and ((ActivityCodeOne = '260') or (ActivityCodetwo =
'260') or (ActivityCodethree = '260') or (ActivityCodeOne
 = '261') or (ActivityCodetwo = '261') or (ActivityCodethree = '261') or
(ActivityCodeOne = '262') or (ActivityCodetwo = '262') or (ActivityCodethree
=
  '262') or (ActivityCodeOne = '263') or (ActivityCodetwo = '263') or
(ActivityCodethree = '263') or (ActivityCodeOne = '264') or (ActivityCodetwo
=
  '264') or (ActivityCodethree = '264') or (ActivityCodeOne = '265') or
(ActivityCodetwo = '265') or (ActivityCodethree = '265') or (ActivityCodeOne
=
  '266') or (ActivityCodetwo = '266') or (ActivityCodethree = '266') or
(ActivityCodeOne = '267') or (ActivityCodetwo = '267') or (ActivityCodethree
=
  '267') or (ActivityCodeOne = '268') or (ActivityCodetwo = '268') or
(ActivityCodethree = '268') or (ActivityCodeOne = '269') or (ActivityCodetwo
=
          '269') or (ActivityCodethree = '269') or (ActivityCodeOne = '279')
or (ActivityCodetwo = '279') or (ActivityCodethree = '279') )



Mark W. Breneman
-Cold Fusion Developer
-Network Administrator
  Vivid Media
  [EMAIL PROTECTED]
  www.vividmedia.com
  608.270.9770

----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to