Create table with name passed as parameter

  • Is it possible to create a new table with a stored procedure, using a table name that is passed into that procedure?  How is this done?

  • You would have to use dynamic sql...something like this...

    DECLARE @tableName varchar(50)

    DECLARE @sql varchar(500)

    SET @sql = 'CREATE TABLE ' + @tablename + ' (Col1 Int, Col2 VarVhar(50), Col3... )'

    EXEC(@sql)







    **ASCII stupid question, get a stupid ANSI !!!**

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

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