select * results from dynamic table

  • Hi All

    I want to produce 'select * from @table' results,@table assigns value at runtime based onuser parameters.

    Is it possible to do so. I Have tried with

    sp_executesql peococedure,but it is not

    working.

    Any Suggestions

    Regards

    Umashankar


    UmaShankar

  • I hope that this is what you were asking for....

    CREATE PROCEDURE usp_dynamic

    @TableName varchar(128)

    as

    DECLARE @SQLstmnt nvarchar(1000)

    SET @SQLstmnt = 'SELECT * FROM ' + @TableName

    EXEC sp_executesql @SQLstmnt

    GO

    If it aint broke don't fix it!


    Andy.

  • Thanks

    UmaShankar


    UmaShankar

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

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