SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 reset Autonumber primary key
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jarv
Posting Yak Master

114 Posts

Posted - 08/02/2007 :  04:18:28  Show Profile  Reply with Quote
Ho wdo i do this? when i delete records and then post a new one from the start I want that to be number 1? I am using MSSQL

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 08/02/2007 :  04:25:42  Show Profile  Visit SwePeso's Homepage  Reply with Quote
DBCC CHECKIDENT


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22761 Posts

Posted - 08/02/2007 :  04:26:18  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
If you meant you want to delete all records and reset it, then truncate the table

Truncate table TableName

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jarv
Posting Yak Master

114 Posts

Posted - 08/02/2007 :  06:18:09  Show Profile  Reply with Quote
how do i do that?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 08/02/2007 :  07:01:43  Show Profile  Visit SwePeso's Homepage  Reply with Quote
???

Madhi just explained and wrote the code for you!

TRUNCATE TABLE <Your Table Name Here>



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

jarv
Posting Yak Master

114 Posts

Posted - 08/02/2007 :  09:59:42  Show Profile  Reply with Quote
do i put that in the SQL string?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 08/02/2007 :  10:23:27  Show Profile  Visit SwePeso's Homepage  Reply with Quote
It depends. What do you mean "sql string"?
We don't have access to your code, and we don't like to guess either.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11751 Posts

Posted - 08/02/2007 :  10:24:54  Show Profile  Visit spirit1's Homepage  Reply with Quote
no

1. open BOL = Books Online = Sql server help
2. type "Truncate table" in the search box
3. go to first result

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

drewsalem
Constraint Violating Yak Guru

304 Posts

Posted - 08/02/2007 :  10:56:07  Show Profile  Reply with Quote
Are you still having problems, Jarv?

Drew
---------------------
"It's Saturday night; I've got no date, a two litre bottle of Shasta, and my all-Rush mix tape... LET'S ROCK."
Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11751 Posts

Posted - 08/02/2007 :  11:01:01  Show Profile  Visit spirit1's Homepage  Reply with Quote
you're in a helping mood today drew

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 08/03/2007 :  12:07:53  Show Profile  Reply with Quote
"I am using MSSQL"
How about, you are connecting to "MSSQL" through a front end, like javascript or some such....

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000