SET @SQL = 'SELECT * FROM ' + @table
EXEC (@SQL) -- parentheses are required
More Related Contents:
- Using “GO” within a transaction
- What’s a good way to trim all whitespace characters from a string in T-SQL without UDF and without CLR?
- Does End Using close an open SQL Connection
- Does this code prevent SQL injection?
- TSQL md5 hash different to C# .NET md5
- How do I write LINQ’s .Skip(1000).Take(100) in pure SQL?
- How can you name the Dataset’s Tables you return in a stored proc?
- Generating sql code programmatically
- SQL query for display one field only once which having multiple record
- How can I convert bigint (UNIX timestamp) to datetime in SQL Server?
- Multi-statement Table Valued Function vs Inline Table Valued Function
- How do you return the column names of a table?
- Dynamically create columns sql
- What’s the best method to pass parameters to SQLCommand?
- INT vs Unique-Identifier for ID field in database
- Why do you create a View in a database?
- SQL query to find Nth highest salary from a salary table
- Cannot use a CONTAINS or FREETEXT predicate on table or indexed view because it is not full-text indexed
- Sanitize table/column name in Dynamic SQL in .NET? (Prevent SQL injection attacks)
- T-SQL: How to use parameters in dynamic SQL?
- Get the records of last month in SQL server
- Merge overlapping date intervals
- Access to Result sets from within Stored procedures Transact-SQL SQL Server
- alternatives to REPLACE on a text or ntext datatype
- Why is some sql query much slower when used with SqlCommand?
- Split words with a capital letter in sql
- SQL poor stored procedure execution plan performance – parameter sniffing
- scope_identity vs ident_current
- Compare dates in T-SQL, ignoring the time part
- Should every SQL Server foreign key have a matching index? [closed]