You will have to change slightly how it does things...

The first part should probably be something like...

CREATE PROCEDURE dbo.DCS_handsets_selected
AS
DECLARE @usockList varchar(2000)

SET @usockList = (SELECT usockCode FROM tbl_dcs_handsets_selected WHERE
handsetid = 1)

The second part AFAIK will require building a string then executing...
Something like

DECLARE @sSQL varchar(2000)
SET @sSQL = 'SELECT usockId, usockCode, usockDesc, usockAmount FROM
dbo.tbl_usocks WHERE  usockDesc LIKE (''%HANDSET%''  AND usockCode  NOT IN
(' + @usockList + ')ORDER BY usockCode, usockDesc'

Exec (@sSQL)

Or something like that...

HTH



-----Original Message-----
From: Bosky, Dave [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 22, 2003 21:37
To: SQL
Subject: SQL statement works but Stored Procedure fails?


I have the following SQL statement that will return all items not in the
list. It works fine as a simple sql statement but when I make a stored
procedure 
with the query it doesn't return the expected results.
This list has been extremely helpful so I thought I might drop it here.
--------------------------------------

SELECT  usockId, usockCode, usockDesc, usockAmount
FROM   dbo.tbl_usocks
WHERE  usockDesc LIKE '%HANDSET%' 
AND usockCode NOT IN ('DCSB01','DCSB02')
ORDER BY usockCode, usockDesc

---------------------------------------

---------------------------------------

CREATE PROCEDURE dbo.DCS_handsets_selected
AS
DECLARE @usockList varchar(2000)

SELECT @usockList = usockCode
FROM tbl_dcs_handsets_selected
WHERE handsetid = 1

SELECT  usockId, usockCode, usockDesc, usockAmount
FROM   dbo.tbl_usocks
WHERE  usockDesc LIKE '%HANDSET%' 
AND usockCode  NOT IN ('@usockList')
ORDER BY usockCode, usockDesc

---------------------------------------

Thanks,
Dave




HTC Disclaimer:  The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of this
message is not the intended recipient, or an employee or agent responsible
for delivering this message to the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
communication is strictly prohibited.  If you have received this
communication in error, please notify us immediately by replying to the
message and deleting it from your computer.  Thank you.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Purchase from House of Fusion, a Macromedia Authorized Affiliate and support the CF 
community.
http://affiliates.macromedia.com/b.asp?id=2439&p=go/ct_aff1

Message: http://www.houseoffusion.com/lists.cfm?link=i:6:1702
Archives: http://www.houseoffusion.com/lists.cfm?link=t:6
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:6
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=<:emailid:>.<:userid:>.<:listid:>

                        

Reply via email to