Monday, March 26, 2012

resetting count on INT type field (autonumber field)

Hi,
I have an INT field that auto increments by 1, now that I am approaching the
end of the testing phase, I need to delete all the records and reset the
"count" to 1.
Any help?
MitchJust truncate the table (or drop and recreate it) since you don't need the
data. Truncate will reset the identity.
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"mitchel" <mitch_001@.yahoo.com> wrote in message
news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I have an INT field that auto increments by 1, now that I am approaching
the
> end of the testing phase, I need to delete all the records and reset the
> "count" to 1.
> Any help?
> Mitch
>|||Sorry, I'm kind of new to SQL server, what does "truncate the table" mean
and how do I do it?
SQL Server 2000
Thanks!
Mitch
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:%23r8XWCV2DHA.2792@.TK2MSFTNGP09.phx.gbl...
> Just truncate the table (or drop and recreate it) since you don't need the
> data. Truncate will reset the identity.
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
>
> "mitchel" <mitch_001@.yahoo.com> wrote in message
> news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I have an INT field that auto increments by 1, now that I am approaching
> the
> > end of the testing phase, I need to delete all the records and reset the
> > "count" to 1.
> >
> > Any help?
> >
> > Mitch
> >
> >
>|||In Query Analyzer run the following in your database
TRUNCATE TABLE name
Have a look at TRUNCATE TABLE in BOL (Books on Line - the SQL Server help)
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"mitchel" <mitch_001@.yahoo.com> wrote in message
news:OWOSvYV2DHA.1704@.tk2msftngp13.phx.gbl...
> Sorry, I'm kind of new to SQL server, what does "truncate the table" mean
> and how do I do it?
> SQL Server 2000
> Thanks!
> Mitch
>
> "Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
> news:%23r8XWCV2DHA.2792@.TK2MSFTNGP09.phx.gbl...
> > Just truncate the table (or drop and recreate it) since you don't need
the
> > data. Truncate will reset the identity.
> >
> > --
> > HTH
> >
> > Jasper Smith (SQL Server MVP)
> >
> > I support PASS - the definitive, global
> > community for SQL Server professionals -
> > http://www.sqlpass.org
> >
> >
> > "mitchel" <mitch_001@.yahoo.com> wrote in message
> > news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
> > > Hi,
> > >
> > > I have an INT field that auto increments by 1, now that I am
approaching
> > the
> > > end of the testing phase, I need to delete all the records and reset
the
> > > "count" to 1.
> > >
> > > Any help?
> > >
> > > Mitch
> > >
> > >
> >
> >
>|||Thanks!
Worked perfectly!
Mitch
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:%23703ihV2DHA.1532@.TK2MSFTNGP10.phx.gbl...
> In Query Analyzer run the following in your database
> TRUNCATE TABLE name
> Have a look at TRUNCATE TABLE in BOL (Books on Line - the SQL Server help)
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
>
> "mitchel" <mitch_001@.yahoo.com> wrote in message
> news:OWOSvYV2DHA.1704@.tk2msftngp13.phx.gbl...
> > Sorry, I'm kind of new to SQL server, what does "truncate the table"
mean
> > and how do I do it?
> >
> > SQL Server 2000
> >
> > Thanks!
> >
> > Mitch
> >
> >
> >
> > "Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
> > news:%23r8XWCV2DHA.2792@.TK2MSFTNGP09.phx.gbl...
> > > Just truncate the table (or drop and recreate it) since you don't need
> the
> > > data. Truncate will reset the identity.
> > >
> > > --
> > > HTH
> > >
> > > Jasper Smith (SQL Server MVP)
> > >
> > > I support PASS - the definitive, global
> > > community for SQL Server professionals -
> > > http://www.sqlpass.org
> > >
> > >
> > > "mitchel" <mitch_001@.yahoo.com> wrote in message
> > > news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
> > > > Hi,
> > > >
> > > > I have an INT field that auto increments by 1, now that I am
> approaching
> > > the
> > > > end of the testing phase, I need to delete all the records and reset
> the
> > > > "count" to 1.
> > > >
> > > > Any help?
> > > >
> > > > Mitch
> > > >
> > > >
> > >
> > >
> >
> >
>

No comments:

Post a Comment