Unix Technical Forum

Subquery parameters

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


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 09:11 AM
Trifix
 
Posts: n/a
Default 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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 09:11 AM
debian mojo
 
Posts: n/a
Default Re: Subquery parameters

The dbo.test proc seems to be working fine!

What error message are you getting?

Regards
Debian



*** Sent via Developersdex http://www.developersdex.com ***
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 09:11 AM
Trifix
 
Posts: n/a
Default Re: Subquery parameters

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 09:12 AM
xAvailx
 
Posts: n/a
Default Re: Subquery parameters

This may be of help:

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

HTH, BZ

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-29-2008, 09:12 AM
--CELKO--
 
Posts: n/a
Default Re: Subquery parameters

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:05 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com