Creating DB Tables in ASP

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Creating DB Tables in ASP

    Hi all

    I'm fairly new to asp & sql.

    using win 2k pro, IIS5, VBscript asp, & SQL SERVER 2k

    I want to know how to create a table in my DB in ASP, the following
    script (below) is what SQLserver2k Generated for me but it seems
    long. Is it possible to put it into 1 create table statement, rather
    than the 3 it has ? any good urls where I can get more info about
    creating DB tables via vbscript?

    thanks
    Al

    '************************************************* ****
    CREATE TABLE [dbo].[TEST] (
    [MemberID] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL
    ,
    [UserName] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS
    NOT NULL ,
    [Pass] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
    NULL ,
    [Text] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    [Age] [tinyint] NOT NULL ,
    [Gender] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
    NULL ,
    [ParentID] [int] NOT NULL ,
    [DateEntry] [smalldatetime] NOT NULL ,
    [DOB] [smalldatetime] NOT NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO

    ALTER TABLE [dbo].[TEST] WITH NOCHECK ADD
    CONSTRAINT [PK_TEST] PRIMARY KEY CLUSTERED
    (
    [MemberID]
    ) ON [PRIMARY]
    GO

    ALTER TABLE [dbo].[TEST] WITH NOCHECK ADD
    CONSTRAINT [DF_TEST_DateEntry] DEFAULT (getdate()) FOR
    [DateEntry],
    CONSTRAINT [DF_TEST_DOB] DEFAULT (getdate()) FOR [DOB],
    CONSTRAINT [IX_TEST] UNIQUE NONCLUSTERED
    (
    [UserName]
    ) ON [PRIMARY]
    GO

    Harag Guest

  2. Similar Questions and Discussions

    1. problems creating innodb tables
      Anytime i create an innodb table mysql connection drops. The frm file gets created, but the table is reported as "in use" and can't be accessed. ...
    2. stop users creating tables
      is there any way to stop users from editing tables and creating new tables without editing the files, and setting them in user roles?
    3. Creating your first site design w/o tables
      I went to the css section of the developers area and started the first webpage design with out tables. I did the whole tutorial and added some of...
    4. Creating tables
      I need to create a table with data similar to a table Dreamweaver. I've readed the help in FreeHand about tables but I've found very dificult to...
    5. Creating curved edged tables in Dreamweaver MX 6 ?
      How can I create curved edged tables (whatever they're called) like the ones at http://www.dmxzone.com or at http://www.ebay.com using Dreamweaver...
  3. #2

    Default Re: Creating DB Tables in ASP

    Put it into a stored procedure and execute the stored procedure from ASP.
    Harag wrote:
    > Hi all
    >
    > I'm fairly new to asp & sql.
    >
    > using win 2k pro, IIS5, VBscript asp, & SQL SERVER 2k
    >
    > I want to know how to create a table in my DB in ASP, the following
    > script (below) is what SQLserver2k Generated for me but it seems
    > long. Is it possible to put it into 1 create table statement, rather
    > than the 3 it has ? any good urls where I can get more info about
    > creating DB tables via vbscript?
    >
    > thanks
    > Al
    >
    > '************************************************* ****
    > CREATE TABLE [dbo].[TEST] (
    > [MemberID] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL
    > ,
    > [UserName] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS
    > NOT NULL ,
    > [Pass] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
    > NULL ,
    > [Text] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    > [Age] [tinyint] NOT NULL ,
    > [Gender] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
    > NULL ,
    > [ParentID] [int] NOT NULL ,
    > [DateEntry] [smalldatetime] NOT NULL ,
    > [DOB] [smalldatetime] NOT NULL
    > ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    > GO
    >
    > ALTER TABLE [dbo].[TEST] WITH NOCHECK ADD
    > CONSTRAINT [PK_TEST] PRIMARY KEY CLUSTERED
    > (
    > [MemberID]
    > ) ON [PRIMARY]
    > GO
    >
    > ALTER TABLE [dbo].[TEST] WITH NOCHECK ADD
    > CONSTRAINT [DF_TEST_DateEntry] DEFAULT (getdate()) FOR
    > [DateEntry],
    > CONSTRAINT [DF_TEST_DOB] DEFAULT (getdate()) FOR [DOB],
    > CONSTRAINT [IX_TEST] UNIQUE NONCLUSTERED
    > (
    > [UserName]
    > ) ON [PRIMARY]
    > GO

    Bob Barrows Guest

  4. #3

    Default Re: Creating DB Tables in ASP

    k Thanks - why didn't I think of that :p

    I've just noticed I got 2 foreign keys (relationships) linking TEST
    table to test_2 & test_3 tables

    Name:
    FK_TEST_2_TEST

    Primary: TEST
    Foreign: TEST_2

    On "MemberID" with both tables
    with Enforce relationship for replication
    & Enforce relationship for Inserts & Updates
    with Cascade delete related records.


    In this example I got TEST_2 holding a Homepage Url as not all members
    have a homepage I've put the url into a seperate table


    How would I create the above key when I create table TEST & TEST_2 via
    the Stored Proc?

    I do have this extra bit at the top now:

    if exists (select * from dbo.sysobjects where id =
    object_id(N'[dbo].[FK_TEST_2_TEST]') and OBJECTPROPERTY(id,
    N'IsForeignKey') = 1)
    ALTER TABLE [dbo].[TEST_2] DROP CONSTRAINT FK_TEST_2_TEST
    GO


    Thanks for the help.
    Al

    On Tue, 12 Aug 2003 11:34:31 -0400, "Bob Barrows"
    <reb_01501@yahoo.com> wrote:
    >Put it into a stored procedure and execute the stored procedure from ASP.
    >Harag wrote:
    >> Hi all
    >>
    >> I'm fairly new to asp & sql.
    >>
    >> using win 2k pro, IIS5, VBscript asp, & SQL SERVER 2k
    >>
    >> I want to know how to create a table in my DB in ASP, the following
    >> script (below) is what SQLserver2k Generated for me but it seems
    >> long. Is it possible to put it into 1 create table statement, rather
    >> than the 3 it has ? any good urls where I can get more info about
    >> creating DB tables via vbscript?
    >>
    >> thanks
    >> Al
    >>
    >> '************************************************* ****
    >> CREATE TABLE [dbo].[TEST] (
    >> [MemberID] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL
    >> ,
    >> [UserName] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS
    >> NOT NULL ,
    >> [Pass] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
    >> NULL ,
    >> [Text] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    >> [Age] [tinyint] NOT NULL ,
    >> [Gender] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
    >> NULL ,
    >> [ParentID] [int] NOT NULL ,
    >> [DateEntry] [smalldatetime] NOT NULL ,
    >> [DOB] [smalldatetime] NOT NULL
    >> ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    >> GO
    >>
    >> ALTER TABLE [dbo].[TEST] WITH NOCHECK ADD
    >> CONSTRAINT [PK_TEST] PRIMARY KEY CLUSTERED
    >> (
    >> [MemberID]
    >> ) ON [PRIMARY]
    >> GO
    >>
    >> ALTER TABLE [dbo].[TEST] WITH NOCHECK ADD
    >> CONSTRAINT [DF_TEST_DateEntry] DEFAULT (getdate()) FOR
    >> [DateEntry],
    >> CONSTRAINT [DF_TEST_DOB] DEFAULT (getdate()) FOR [DOB],
    >> CONSTRAINT [IX_TEST] UNIQUE NONCLUSTERED
    >> (
    >> [UserName]
    >> ) ON [PRIMARY]
    >> GO
    >
    Harag Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139