Results 1 to 4 of 4

Thread: sql server help

  1. #1
    Join Date
    Aug 2006
    Posts
    1

    Thumbs up Unanswered: sql server help

    hi i have a small issue.\
    is it possible to add an INDEX using ALTER TabLE statement in sqlserver

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i don't think so

    you can use CREATE INDEX to add an index after the table already exists
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I asked this question once too. Blindman's response was as Rudy's. As he pointed out - an Index is a separate object associated with the table but not part of its definition.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    A lot depends on just how you define "create an index". It so happens that SQL Server actually does create indicies in order to enforce a PRIMARY KEY or a UNIQUE constraint, so even though you are not explicitly creating an index, you actually do create an index as a side effect of the ALTER TABLE statement. Depending on how the question was defined, this might qualify.

    -PatP

Posting Permissions

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