Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

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)

Posted
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)

Posted

But will that affect the relationships I have set-up between my datatables?

 

Mike55

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)

Posted

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!

Posted

Genius...What else can I say...Thanks IUnknow.

 

Mike55.

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)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...