Skip to main content
3 of 3
added 36 characters in body
Thomas Stringer
  • 42.4k
  • 9
  • 119
  • 155

I think your best bet is to use dynamic SQL to accomplish this:

create procedure myprocedure
@tableName nvarchar(50) = ''
as

    declare @sql_cmd nvarchar(200) 
    set @sql_cmd = 'select blah from ' + QUOTENAME(@tableName) + ' where blah = blah2'
    
    exec (@sql_cmd)

go
Thomas Stringer
  • 42.4k
  • 9
  • 119
  • 155