Monday, March 19, 2012

can the talbe name be a parameter of a query line?

the tables are created by month, and the table names are like
wt01,wt02.........
and the structure of tables are all the same,
can the talbe name be a parameter of a query line?
like select * from @.TableName ?
if not, how to make it possible to query different tables by parameter?declare @.tbl sysname
exec ('select * from ' + @.tbl)
OR
="Select * from " & Parameters!Tablename.Value
either should work
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
I support the Professional Association for SQL Server ( PASS) and it''s
community of SQL Professionals.
"Spirit" wrote:
> the tables are created by month, and the table names are like
> wt01,wt02.........
> and the structure of tables are all the same,
> can the talbe name be a parameter of a query line?
> like select * from @.TableName ?
> if not, how to make it possible to query different tables by parameter?
>|||but when I execute the code in the query Analysis,it reports 170 error
and there is some error near from...|||thank you for your help
it is ok now

No comments:

Post a Comment