Solved

Changing the Primary Key Index SQL Compact 3.5

Posted on 2012-04-01
3
647 Views
Last Modified: 2012-09-02
I have a small SQL CE 3.6 *.SDF Database File which contains 3 tables.
I noticed there is an error on one of the tables. The primary key index starts at 1 but I need it to be 0. How can I change this without recreating the table?
0
Comment
Question by:soulhero
[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
3 Comments
 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 37794045
I assume it's an identity column, otherwise a simple sql update statement would suffice.  Though, I must say, if it's a clustered index even the simple sql update would amount to a rebuild of the entire table.  So, I'm not sure why you are avoiding the re-create.  

I'm also a little confused by the notion of using identity (which implies no business meaning) and then insisting on a seed starting with 0 (which implies the opposite).  If you are feeling a need to control the values assigned to your PK, then perhaps idenitity is not such a good idea.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

705 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