I need to pull records from a table and that would be pretty simple, however, the select statement needs to run as a sproc that passes a variable input as the table name. Let me illustrate:
create procedure dbo.sproc
Select cust#, fname, lname... other fields
Where Cust# in (Select Cust# from @Tablename)
the error is telling to declare the table variable, but if I declare it as table I have to include the fields and I dont want to. Does this work better with dynamic SQL? What's the best way to do this?