471,090 Members | 1,410 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,090 software developers and data experts.

Subquery parameters

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?

Jul 23 '05 #1
4 4553
The dbo.test proc seems to be working fine!

What error message are you getting?

Regards
Debian

*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #2
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

Jul 23 '05 #3
This may be of help:

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

HTH, BZ

Jul 23 '05 #4
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.

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by lev | last post: by
3 posts views Thread by Maarten | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.