Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sub Queries and Parameters

Author  Topic 

Mr_Wombat
Starting Member

2 Posts

Posted - 2003-01-30 : 00:46:40
Hi there. Ok firstly i am just in the learning stages of SQL I am querying a SQL Server Database with this query.
SELECT ELECTRICAL_ENQ.*
FROM ELECTRICAL_ENQ
WHERE (EleID NOT IN
(SELECT Electrical_Response.EleID
FROM Electrical_Response
WHERE ELECTRICAL_RESPONSE.SupID = @supID))
Now if i change the Parameter @supId with a value the query works fine but as soon as i putthis parameter in it comes up with the error:
Parameter information cannot be derived from sql statements with sub queries. Set parameter information before preparing command.
The only problem with this is i dont knw how. Anyone have some helpfull advice they would like to throw this way?
Cheers in Advance

nr
SQLTeam MVY

12543 Posts

Posted - 2003-01-30 : 01:07:40
looks like this should work.
how are you executing the statement? In query analyser?

and how is @supID declared

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.

Edited by - nr on 01/30/2003 01:10:00
Go to Top of Page

Mr_Wombat
Starting Member

2 Posts

Posted - 2003-01-30 : 01:16:34
It is executed as a SQL statement in .net that then performs that statement upon SQL Server. I dont mind using it as a stored procedure in SQL Server but unfortunetly i dont know how to write it for SQL Server.
The statement does work if i substitute the @supID with a value but i am guessing .net doesnt like having the variable in the sub query.
Cheers

Go to Top of Page
   

- Advertisement -