| Author |
Subquery parameters
|
|
| Trifix 2005-06-27, 7:23 am |
| 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?
| |
| debian mojo 2005-06-27, 7:23 am |
| The dbo.test proc seems to be working fine!
What error message are you getting?
Regards
Debian
*** Sent via Developersdex http://www.droptable.com ***
| |
| Trifix 2005-06-27, 9:23 am |
| Thanks for your answer.
There are some problems when you assign to parameter @valore the value
'1, 2', for example.
EXEC dbo.test '1, 2'
Regards
Maurizio
| |
|
|
| --CELKO-- 2005-06-27, 8:23 pm |
| 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.
|
|
|
|