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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

how do i do this in SQL????

  • 12-12-2003 2: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, Registered Users 2 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, Registered Users 2 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