on 07-01-2008 7:10 PM
Hi all,
I'm not sure that this is the right forum for this question, but I'll try.
I want to build stored procedure that will receive parameter of varchar type and use it in select statement as table name.
This one doesn't work:
CREATE PROCEDURE [XXX].[GetAllFromTable]
@TableName varchar(30)
AS
BEGIN
SELECT * from @TableName
END
The error is
Must declare the table variable "@TableName".
How can I do it? Is it possible?
Thanks,
Ola
create procedure test_sp
@table_name varchar(30)
as
set nocount on
exec('set transaction isolation level read uncommitted select * from '+@table_name)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.