Re: sql script

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Martin Selway (martin.selway_at_casserviceltd.com)
Date: 11/05/04


Date: Fri, 5 Nov 2004 10:18:23 -0000

You need to drop the PK constraint, drop the existing index, create the new
clustered index then create the PK constraint.

"ichor" <ichor@hotmail.com> wrote in message
news:uFQQrPuwEHA.1260@TK2MSFTNGP12.phx.gbl...
> hi i need to write a script that converts a non-clustered index to a
> clustered index. anyone know how. the table is very huge and has about 5
> million recs.
>
> create NONCLUSTERED INDEX [PK_Table1] ON [dbo].[Table1]([id]) WITH
> FILLFACTOR = 90 ON [PRIMARY]
>
> this is the index and its the primary key of a table.
> i need to write a script so that i can just execute it on the server. i
can
> do this using the GUI that SQL SErver 2000 provides. but have to write the
> script. any one know how?
>
> Thnx
>
>



Relevant Pages

  • Re: variables in constraints, scripting partition sliding
    ... The date should appear in quotes in the constraint definition. ... So that if the script is not run, the table can still accomodate the ... set an upper limit when you create the next partition. ... Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books ... ...
    (comp.databases.ms-sqlserver)
  • Re: how to drop index?
    ... coresponding END in your IF Statement, because you are dividing your script ... which is the unit of Parsing and Compilation for SQL Server. ... > I want to check for duplicate data, if got duplicate data, then the ... > tell me the correct way to drop the constraint and index? ...
    (microsoft.public.sqlserver.server)
  • Re: Delete from takes a very, very long time
    ... CONSTRAINT PRIMARY KEY CLUSTERED ... This is from the create script. ... > I dont think this table has a clustered index on it ...
    (microsoft.public.sqlserver.programming)
  • Re: How to avoid nonclustered index creation ?
    ... I guess the simple answer is t have a clustered index on the PK, ... If the script won't run on SQL Server and you also have ... SQL Server subscribers, you could do a noinit subscription for the latter. ...
    (microsoft.public.sqlserver.replication)
  • Re: variables in constraints, scripting partition sliding
    ... The date should appear in quotes in the constraint definition. ... So that if the script is not run, the table can still accomodate the ... set an upper limit when you create the next partition. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)