use variable for the name of a table

  • I want to do this, i don´t know if it is posible

    declare @name_table1

    select * from @name_table1

    I have problems.

    thanks

  • you will have to executed the command with EXECUTED()

    declare @name_table1

    select * from @name_table1

    EXEC ('select * from ' + @name_table1

    )

    Felix

  • quote:


    I want to do this, i don´t know if it is posible

    declare @name_table1

    select * from @name_table1

    I have problems.

    thanks

    I don´t want to use execute


  • Then you'll have to build the sql on the client.

    Andy

  • Andy is right. SQL (at least at this point) does not accept variables for DB, Table or Column name replacement. You will have to use EXEC.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

    Edited by - antares686 on 05/21/2002 09:27:45 AM

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

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