Home > Archive > Microsoft SQL Server forum > June 2005 > Subquery parameters









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

xAvailx

2005-06-27, 8:23 pm

This may be of help:

http://www.sommarskog.se/arrays-in-sql.html#problem

HTH, BZ

--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.

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com