Search code examples
sqlstored-proceduressql-server-2000

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


Solution

  • 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