Solved

how do I alter table to remove unique field

Posted on 2013-11-04
9
253 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Invalid Identifier Error 3 65
Oracle Pivot 2 32
query question 13 41
Updating ms sql with special characters 8 20
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

15 Experts available now in Live!

Get 1:1 Help Now