Solved

how do I alter table to remove unique field

Posted on 2013-11-04
9
254 Views
Last Modified: 2013-11-08
SET QUOTED_IDENTIFIER ON
GO
I have the following table.  How do I alter the table to remove unique from field ViewName by iteself.

IDRoleApps and ViewName together is fine.


CREATE TABLE [dbo].[ViewName](
      [IDViewName] [bigint] IDENTITY(1,1) NOT NULL,
      [ViewName] [nvarchar](50) NOT NULL,
      [ViewType] [nvarchar](50) NOT NULL,
      [ViewDescription] [nvarchar](255) NOT NULL,
      [IDRolesApps] [bigint] NULL,
 CONSTRAINT [ViewName_PrimaryKey] PRIMARY KEY CLUSTERED
(
      [IDViewName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IDViewName] UNIQUE NONCLUSTERED
(
      [ViewName] ASC,
      [IDRolesApps] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
      [ViewName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
0
Comment
Question by:goodk
  • 5
  • 4
9 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39622976
It appears to be added as a Unique Index and without a name supplied by the code. I suspect it will have a system generated name which you will have to retrieve and  then use to drop the Indie (or possibly a constraint).


Kelvin
0
 

Author Comment

by:goodk
ID: 39623257
Hi Kelvin,

How do i find the unique index? and then how do i use it to alter the table to remove unique index from Viewname field?
0
 

Author Comment

by:goodk
ID: 39623264
Hi Kelvin,

How do i find the system generated name? and then how do i use it to alter the table to remove unique index from Viewname field?
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39623267
Do you have access to the database itself via SSMS?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:goodk
ID: 39623272
I am using MS sql server management studio and I can run queries on the sql db.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39623281
OK, open the table in design, right click in and empty part of the designer and choose Indexes.

Review those list - lick each in turn on the left and see which fields are included in the right hand panel. The names on the left are the Index (or constraint names). You can delete it there by selecting it and deleting or using the syntax

ALTER TABLE tablename DROP CONSTRAINT indexname

Kelvin
0
 

Author Comment

by:goodk
ID: 39623298
It is a shared db so can see the design but cannot interact or modify it.

Alter table commands would work.
0
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 500 total points
ID: 39623309
OK, use the management studio to see the index as described above, then use the name in the statement supplied above.


Kelvin
0
 

Author Closing Comment

by:goodk
ID: 39634686
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now