-
How to use a parameter variable in FROM clause at SQL SERVER
Hi,
I'm working with Visual Basic using SQL SERVER to manage my databases.
I have several tables in my database and I need to do a SELECT from a specific table so I must pass the name of the table as a parameter using a stored procedure:
CREATE PROCEDURE Obt_Inc_Month(@month char(5))
AS
SELECT *
FROM [@month]
GO
When I try to obtain the results fromm Visual Basic:
...
Call Data.Obt_Inc_Month("Jan02"
Set rsMonth = Data.rsObt_Inc_Month
...
There is an error calling the procedure Obt_Inc_Month("Jan02"
Error:
"Invalid object name @month"
Please, anybody knows how can I use a parameter variable as a table name to make a SELECT on it?
Thank you all.
Loli
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|