Variable in 'From' Clause of Stored Procedure .....
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sally_hudson
Posted On:   Thursday, October 18, 2001 06:47 AM

Hi, Can't we pass a variable in the 'FROM' clause of the stored procedure ???? As if I give the table name instead of the variable then my StoredProcedure compiles without any error ..... I am passing a variable @table_name while creating a procedure, but In the From clause if I put that variable tehn the Stored Procedure doesnot execute and gives an error as : "Line 9: Incorrect syntax near '@table_name'." My Procedure is as follows..... Create Procedure sp_getTableRecords @table_name varchar(36) , @Page int, @Size int AS SELECT * from @table_name I will appreciate if someone can help me .... Thanks!    More>>

Hi,
Can't we pass a variable in the 'FROM' clause of the stored procedure ???? As if I give the table name instead of the variable then my StoredProcedure compiles without any error .....

I am passing a variable @table_name while creating a procedure, but In the From clause if I put that variable tehn the Stored Procedure doesnot execute and gives an error as :
"Line 9: Incorrect syntax near '@table_name'."


My Procedure is as follows.....

Create Procedure sp_getTableRecords

@table_name varchar(36) ,
@Page int,
@Size int


AS
SELECT * from @table_name



I will appreciate if someone can help me ....
Thanks!

   <<Less
About | Sitemap | Contact