Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Setting output parameters with dynamic SQL in a St. Proc.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-22 : 06:58:44
Derek writes "Is it possible to somehow set the output parameters in a stored procedure from dynamic SQL? I have a new db that must interface with a poorly designed system using only stored procedures. This is actually the inverse of the question here: Multiple Joins to the same Table in a Query

I have a table such as:

Fruits
------------------------
fruit_location_ID int,
fruit_name varchar(50),
fruit_color varchar(50),
fruit_min_weight decimal(8,4),
fruit_max_weight decimal(8,4)

The old database for this system had one big table with all of the above values in a single row per location. For instance:

fruit_location_ID int, fruit_1_name varchar(50), ..., fruit_n_max_weight (in my case n = 28)

Obviously it is tedious to write out all of these output parameters and set all of them. Since the only variance of the output parameter names is the number, is there a way to automate that with some sort of loop?

Windows Ver: Windows Server 2003 x64 Standard
SQL Server Ver: MS SQL 2000 SP4 Standard"

nr
SQLTeam MVY

12543 Posts

Posted - 2005-08-22 : 08:42:25
see
http://www.mindsdoor.net/SQLTsql/sp_executeSQL.html
That is calling an sp but works for setting a variable in dynamic sql too.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -