Monday, March 26, 2012

Reseting Indexes

I just migrated a Microsoft Access 2002 database to SQL Server 2005. So far
everything is working great. While updating my Access.mdb file to an
Access.ADP file I've been testing adding, editing and deleting records to
various tables so that I can ensure my Stored Procedures are working
properly.
Now, I have deleted much of my sample data and want all of my indexes to
restart with the lowest number, typically being Number 1. In Access, I would
empty the table, then compact/repair the database and the indexes would be
reset. How do I achieve this with SQL Server 2005 for the following two
examples.
1. No records in the table, so I want to have the index restart at Number 1.
2. I have records in the table (i.e. records 1 to 9) and I want the next
index to start at 10. In this example, my index is currently starting at 23
becuase I've added records to the table and deleted some.
Thank You.<DIV>"Greg" <AccessVBAnet@.newsgroups.nospam> wrote in
message news:BFDAB950-91CD-4248-B042-6008C35A05ED@.microsoft.com...</DIV>>I
just migrated a Microsoft Access 2002 database to SQL Server 2005. So far
> everything is working great. While updating my Access.mdb file to an
> Access.ADP file I've been testing adding, editing and deleting records to
> various tables so that I can ensure my Stored Procedures are working
> properly.
> Now, I have deleted much of my sample data and want all of my indexes to
> restart with the lowest number, typically being Number 1. In Access, I
> would
> empty the table, then compact/repair the database and the indexes would be
> reset. How do I achieve this with SQL Server 2005 for the following two
> examples.
> 1. No records in the table, so I want to have the index restart at Number
> 1.
> 2. I have records in the table (i.e. records 1 to 9) and I want the next
> index to start at 10. In this example, my index is currently starting at
> 23
> becuase I've added records to the table and deleted some.
>
You mean "identity columns" not "indexes" (although your identity columns
are probably indexed).
DBCC CHECKIDENT (Transact-SQL)
http://msdn2.microsoft.com/en-us/library/ms176057.aspx
David|||Excellent. That accomplished what I was looking for. And, yes, I was
referring to Identity Columns, which are indexed.
Thank You
"David Browne" wrote:

>
> <DIV>"Greg" <AccessVBAnet@.newsgroups.nospam> wrote in
> message news:BFDAB950-91CD-4248-B042-6008C35A05ED@.microsoft.com...</DIV>>I
> just migrated a Microsoft Access 2002 database to SQL Server 2005. So far
> You mean "identity columns" not "indexes" (although your identity columns
> are probably indexed).
> DBCC CHECKIDENT (Transact-SQL)
> http://msdn2.microsoft.com/en-us/library/ms176057.aspx
> David
>

No comments:

Post a Comment