This is a discussion on Subquery parameters within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello all, I have a stored procedure with a parameter that I need to use in a subquery, but ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello all, I have a stored procedure with a parameter that I need to use in a subquery, but my query doesn't work. The stored procedure is some as: CREATE PROCEDURE dbo.Test @valore varchar(100) AS SELECT * FROM TABELLA WHERE i_campoID IN (@valore) ORDER BY i_campoID DESC GO How can I do, without using EXECUTE command? |
| |||
| The dbo.test proc seems to be working fine! What error message are you getting? Regards Debian *** Sent via Developersdex http://www.developersdex.com *** |
| |||
| |
| ||||
| You do not understand that SQL is a compiled language and that parameters are scalar values. BASIC programmers seem to make this error often. SQLK programmers do not write that kind of code. You probably meant something like this: SELECT {{ column list }} -- never use * in production code! FROM Tabella WHERE campo_id -- never put the datatype in a data element name-ISO-11179 IN (SELECT parm FROM ParmList WHERE parm IS NOT NULL); You then have to put you valeus in the ParmList table. |