Out of interest, why do you want to update the primary key column and keep it as a continious number series ? if does not needs to be. updating the primary key column may defeat the idea the relational database when it comes to many table connected to your table.. Change sql server primary key using c#. ask question. up vote 1 down vote favorite. i need to change a column type in a sql server table. i need do it using a script or c#. how do i update from a select in sql server? 532. reset identity seed after deleting records in sql server.. The primary key of a row is meant to uniquely identify a row (in the case of linq to sql, an object). if you're modifying the primary key, in reality you're creating a new unique object with the same fields as another..
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. I need to be able to change the primary keys in a table. the problem is, some of the keys will be changing to existing key values. e.g. record1.id 3=>4 and record2.id 4=>5. i need to keep these as primary keys as they are set as foreign keys (which cascade up update) is there a reasonable way to accomplish this, or am i attempting sql heresey?. I have a country table which have a column countryid i accidently deleted the countryid which had value=1 and now in state table there is a value of column countryid=1 which is used to fetch the records (states) according to country id. i had inserted the country again but it has different id so how can i update the value again in country table of countryid which primary key from 2 to.