mike55 Posted September 27, 2006 Posted September 27, 2006 Hi all I am currently experimenting with FitNesse, which is an automated acceptance testing tool. Now to run my fit test, I have to clear my database of all the data. I am therefore using "Delete From <<table>>", and replacing <<table>> with the name of the table. Some of my tables have an id column that is auto-incrementing. My questions is therefore, can I reset the column id back to 0 using sql code? Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Gill Bates Posted September 28, 2006 Posted September 28, 2006 I'm pretty sure the only way you can do this is by dropping the column and then adding it again.ALTER TABLE dbo.MyTable DROP COLUMN MyIdentityCol ALTER TABLE dbo.MyTable ADD MyIdentityCol int NOT NULL IDENTITY (0, 1) Quote
mike55 Posted September 28, 2006 Author Posted September 28, 2006 But will that affect the relationships I have set-up between my datatables? Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
IUnknown Posted September 28, 2006 Posted September 28, 2006 Try something like DBCC CHECKIDENT('<<table>>', RESEED, 0)I used 0 as the seed, of course you may use another value to reseed (same as what you used originally). Hope this helps! Quote
Gill Bates Posted September 28, 2006 Posted September 28, 2006 Oh, nice. I didn't know about that function. Quote
mike55 Posted October 1, 2006 Author Posted October 1, 2006 Genius...What else can I say...Thanks IUnknow. Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.