how to create table inside stored proc

  • I am new to T-SQL. How do I write the portion in blue?

    set quoted_identifier on

    GO

    if exists (select * from sysobjects where id = object_id(N'[dbo].[MyTable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

    -- need to output message that MyTable already exists

    else

    -- how to create the table here?

    CREATE TABLE "dbo"."MyTable" (

     "username" varchar (64) NOT NULL ,

     "moduleID" varchar (100) NULL

    )

    end if;

    GO

  • if exists (select * from sysobjects where id = object_id(N'[dbo].[MyTable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

    PRINT 'MyTable already exists'

    else

    CREATE TABLE dbo.[MyTable] (

    [username] varchar (64) NOT NULL ,

    [moduleID] varchar (100) NULL

    )

    end if;

    _____________
    Code for TallyGenerator

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

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