Results 1 to 2 of 2

Thread: SQL Server stored procedures

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Dear All,
    I would like to execute a DDL statement(create table) in an SQL server stored procedure. I am formulating the DDL statement in the stored procedure and is saved in a variable of type varchar. How do I execute that DDL statement.
    Thanks in advance

  2. #2
    Fanatic Member
    Join Date
    Aug 2000


    Just a quick example
    create proc sp_AdhWmCreateRXCRTables with recompile as

    declare @command varchar(60)
    declare @usename varchar(60)

    set nocount on

    select @usename = "tblmsdnexpert"
    if OBJECT_ID(@usename) is not null
    select @command = 'DROP TABLE ' + @usename
    exec (@command)

    select @command = 'CREATE TABLE(......etc"

    exec (@command) should do it...

    I hope I understood your question correctly..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width