Solved

how do I alter table to remove unique field

Posted on 2013-11-04
9
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39623267
Do you have access to the database itself via SSMS?
0
 

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

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…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

734 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