Thursday, May 23, 2019

Update Table Without Primary Key Sql Server






I have a simple table in sql 2008 having no primary key. the structure of table as follows: ename -> varchar(20) edesc -> varchar20) edept -> varchar(20) i have put some values in the datagrid view and want to save in the sql server. the commandbuilder object does not allow me to create the update and delete command without pk. i dont want to. If you need a deterministic update, you don't have many options without a key. the best bet might be the optimistic concurrency hack, viz extending the where to include all columns of the previously known value of the record, i.e.. I have several tables whose only unique data is a uniqueidentifier (a guid) column. because guids are non-sequential (and they're client-side generated so i can't use newsequentialid()), i have made a non-primary, non-clustered index on this id field rather than giving the tables a clustered primary key..












Update(2/11/2018): i added the [key] annotation on the activityid property, and that made ef core happy and allow my query to go through. i did not need to add primary key attribute on the table in the sql server, which would be wrong in terms of business logic anyway. however, i still think ef core should support table without primary keys.. Actually: having a primary key (which by default also is the clustering key) can actually speed up many operations on sql server tables - even if the key itself is not really needed. the point is: without a clustering key, the table is a "heap" which uses a rather messy structure and organization.. I know the simple way to perform update or insert is using 'replace' but it needs a primary key, how about in the case of a table without primary key? i have 5 columns in my table: remark_id(the auto-increment primary key).



update table without primary key sql server

visit link reference