BradEdwards
Technical User
I created a stored procedure called spStaffingModelsRpt that passes the name of the month as @Month. I then create a #Temporary table that selects records from the @Month table but it will not allow me to use @Month in the FROM Clause. I saw another posting that said to create the SQL statment dynamically i.e.
Select @dynamicQuery = 'Select * from ' + @Month
Exec @dynamicQuery
But when I run 'exec spStaffingModels 'July' through an SQLPassThrough query in Access, it says it "could not find stored procedure 'S'. (#2182)". Following is a VERY simplified version of my stored procedure:
CREATE PROCEDURE spStaffingModelsRpt (@Month varchar)
AS
DECLARE @dynamicQuery varchar
SELECT @dynamicQuery = 'Select * from ' + @Month
EXEC @dynamicQuery
Am I doing something wrong? Please help!!!
Select @dynamicQuery = 'Select * from ' + @Month
Exec @dynamicQuery
But when I run 'exec spStaffingModels 'July' through an SQLPassThrough query in Access, it says it "could not find stored procedure 'S'. (#2182)". Following is a VERY simplified version of my stored procedure:
CREATE PROCEDURE spStaffingModelsRpt (@Month varchar)
AS
DECLARE @dynamicQuery varchar
SELECT @dynamicQuery = 'Select * from ' + @Month
EXEC @dynamicQuery
Am I doing something wrong? Please help!!!