Get values from not defined table

  • Hallo,

    Does anybody know how to make a function or stored procedure with input TABLENAME and value1. The output should be a selection from the given table (TABLENAME) and criteria value1. The problem is, I cann't declare te output table because i've more then 100 tables with variable number of collumns and collumn names.

    Also when it is impossible, please tell me

    thanks in advance

  • It requires you to use Dynamic SQL like so

    CREATE PROCEDURE ip_SP

    @tablename varchar(255)

    AS

    EXEC('SELECT * FROM ' + @tablename)

    or some other similar type of Dynamic SQL.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply