Hi,
I'm adapting access queries to sql server and I have difficulties with
the following pattern :
query1 : SELECT * FROM Query2 WHERE A=@param1
query 2: SELECT * FROM Table2 WHERE B=@param2
The queries are nested, and they both use parameters.
In MS Acccess the management of nested queries with parameters is so
easy (implicit declaration of parameters, transmission of parameters
from main query to nested query)
that I don't know what the syntax should be for stored procedures.
The corresponding stored procedure would be something like
CREATE TABLE #TempTable (...table definition...)
INSERT INTO #TempTable ExecProc spQuery2 @Param2
SELECT * FROM #TempTable WHERE A=@Param1
And spQuery2 would be : SELECT * FROM Table2 WHERE B=@Param
I was wondering if this syntax would work and if I can skip the
explicit declaration of #TempTable definition.
Thanks for your suggestions.
I'm adapting access queries to sql server and I have difficulties with
the following pattern :
query1 : SELECT * FROM Query2 WHERE A=@param1
query 2: SELECT * FROM Table2 WHERE B=@param2
The queries are nested, and they both use parameters.
In MS Acccess the management of nested queries with parameters is so
easy (implicit declaration of parameters, transmission of parameters
from main query to nested query)
that I don't know what the syntax should be for stored procedures.
The corresponding stored procedure would be something like
CREATE TABLE #TempTable (...table definition...)
INSERT INTO #TempTable ExecProc spQuery2 @Param2
SELECT * FROM #TempTable WHERE A=@Param1
And spQuery2 would be : SELECT * FROM Table2 WHERE B=@Param
I was wondering if this syntax would work and if I can skip the
explicit declaration of #TempTable definition.
Thanks for your suggestions.
Comment