Without an EXEC statement, you would need to do something like this.
If @tbl_name = 'Table1'
Begin
Select * From Table1
Return
End
If @tbl_name = 'Table2'
Begin
Select * From Table2
Return
End
... If statements and tables
If @tbl_name = 'TableN'
Begin
Select * From TableN
Return
End If you want to get the best answer for your question read faq183-874 and faq183-3179. Terry L. Broadbent - DBA
SQL Server Page:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.