[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2196
  • Last Modified:

Can't perform Create, Update or Delete operations on 'Table(Table Name)' because it has no primary key.

When I try to perform any of the above functions (Create, Update, and Delete) I receive the above error message.  My Table does have a primary key called RowID datatype int.  I am using LINQ to connect to my SQL database.

What else needs to be modified?
0
Robert Treadwell
Asked:
Robert Treadwell
  • 3
1 Solution
 
chapmandewCommented:
you can add this to the table


alter table tablename
add idcolumn int identity(1,1) primary key
0
 
chapmandewCommented:
quick change:

alter table tablename
add idcolumn int not null identity(1,1) primary key
0
 
Robert TreadwellAuthor Commented:
Thank you for your help.

I already have a Row ID column so I will need to alter it.  Is this the right syntax for SQL Server 2008?  The reason I ask is that when I execute it doesn't make the modifications requested.

ALTER TABLE [Annoucements Current Events]
ALTER COLUMN RowID int not null IDENTITY(1,1) primary key;
Select Top 1000 * from [Annoucements Current Events]
0
 
chapmandewCommented:
try to make the change through the ssms interface rather than through tsql code.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now