I need to select *from (parm)_NAME and use the data in that table for the report.

  • I need to do a report where the user will select from a parm list: MTN, ACC, MKT

    I have tables like:

    MTN_NAME

    ACC_NAME

    MKT_NAME

    MTN_DETAIL

    ACC_DETAIL

    MKT_DETAIL

    I need to select *from (parm)_NAME and use the data in that table for the report.

    This may be simple but I'm new at this and don't know how to write the query.

    :unsure:

    Changinagain

  • BKW - have you thought of creating a dynamic T-SQL statement such as

    CREATE PROCEDURE Dbo.GetIT

    @TableName VARCHAR(5)

    AS

    DECLARE @Sql VARCHAR(50)

    SET @Sql = 'SELECT * FROM ' + @TableName + '_Name'

    PRINT @Sql -- print to be sure it is correct

    EXECUTE @Sql -- add this to execute after verifying it is correct

    Run as

    dbo.getit 'mystu'

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • I'll try that, thx

    Changinagain

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

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