Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

how do i do this in SQL????

Options
  • 12-12-2003 3:47pm
    #1
    Moderators, Society & Culture Moderators Posts: 2,688 Mod ✭✭✭✭


    I need a stored procedure that takes in a string from VBA
    and uses it to create a table,
    i know how to write stored procedures and all that but i want something like this....


    declare @mystring as string
    @mystring = 'table name'
    Create Table @mystring ( etc etc etc....



    is this possible ???:confused:


Comments

  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    There is no technical limitation to prevent you from creating a table inside a stored procedure.

    However, you cannot put @variable values into the CREATE TABLE statement like your example. At least, I'm pretty sure you can't....for the same reason you can't have a stored proc which allows you to do "select * from @myTable"

    What you end up needing to do is to actually build a string which contains the CREATE TABLE statement, and which then use the EXEC function to carry out the operation.....

    At that point, the Stored Procedure is really only additional overhead, and you end up needing to question why you're using it.

    jc


  • Registered Users Posts: 3,312 ✭✭✭mr_angry


    Its pretty easy to do in VBA. I presume its at least possible in a stored procedure, although I've never tried it, so I wont comment!


Advertisement