IF EXISTS (SELECT * FROM sysobjects WHERE name = '<pkname>')
BEGIN
ALTER TABLE <tablename>
DROP CONSTRAINT <pkname>
ALTER TABLE <tablename>
ADD CONSTRAINT <pkname>
PRIMARY KEY CLUSTERED/NONCLUSTERED (<col1>, <col2>,...<coln>)
END
P
-----Original Message-----
From: Dylan Jones
[mailto:mssqldba-ezmlmshield-x49908773.[Email address protected]
Sent: Tuesday, February 22, 2005 1:53 PM
To: LazyDBA Discussion
Subject: T-SQL to drop and add primary key
BOL offers so many choices any one have a script handy that shows an
example of dropping and adding a multi-column primary key?
Thanks in advance
Dylan
Get the latest news on SurfControl and our products,
subscribe to our monthly e-newsletter, SurfAdvisory at:
http://www.surfcontrol.com/resources/surfadvisory/surfadvisory_signup.aspx
*********************************************************************
The information in this email is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this
email by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution or any action taken
or omitted to be taken in reliance on it, is prohibited and may be
unlawful. If you believe that you have received this email in error,
please contact the sender.
*********************************************************************
SurfControl Inc.
5550 Scotts Valley Drive
Scotts Valley, California 95066
831-440-2500
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
Website : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
For additional commands, e-mail: mssqldba-[Email address protected]
MS Sql Server LazyDBA home page