简体   繁体   中英

SQL Server 2000 - Stored procedure parameter values with a SELECT statement

I'm trying to call a stored procedure from within another stored procedure. What I want to do is SELECT the value of my parameters from a table, however SQL server rejects this.

EXEC sp_MyStoredProcedure
                @ipParm01 = (SELECT value1 FROM table1 WHERE condition1),
                @ipParm02 = (SELECT value2 FROM table2 WHERE condition2),
                @ipParm03 = (SELECT value3 FROM table3 WHERE condition3)

The error I'm getting is

Incorrect syntax near '('.

Can this be done, or should I declare a bunch of variables, fill them with the values from the select statements, use them in the EXEC sp?

Thanx guys!!!

First thing you should do is upgrade your RDBMS

Solution

You are possibly looking for something Like

 SELECT @ipParm01 = value1 FROM table1 WHERE condition1 SELECT @ipParm02 = value2 FROM table2 WHERE condition2 SELECT @ipParm03 = value3 FROM table3 WHERE condition3 

And then Do

 EXEC sp_MyStoredProcedure @ipParm01, @ipParm02, @ipParm03 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM