I have red this thread while I was searching an answer to my problem. Basically when you develop an app. you do some testing to check if everything is fine. When the testing is done you have primary key seeds starting from a number x which is not 1, as it is when the db is newly created.
I read about the truncate instruction (which I knew from mysql) but I can't perform the query because of the presence of a foreign key constraint in another table.
So I thought, maybe there is a way to tell the DB engine to disable FK checks while I do the truncation, but I can't find it in the documentation.
So the question is: using SQL EXPRESS what is the quickest way to reset the db state to its initial state, where all the primary key seeds were 1?
thanks in advance and sry if this question is already answered somewhere else, I searched but I didn't find a solution.
sfabrizIf you want to create the database from scratch, what about dropping the whole database and recreating it as a new one ?
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||That would be a very good solution. The problem is that I don't know how to dump the schema. I mean, I don't know how to get to a sql script that, after running, would recreate my db.
Is there a tool in VS2005 to do this? Man I'm noob in handling SQL EXPRESS databases and I'm so used to phpMyAdmin... :)
Sfabriz|||You could get familiar with the Data Dude. At this time (during the beta) it is free to use and provides a nice GUI to administer your database during the development process and also script out your database as a whole :-)
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=833748&SiteID=1
Otherwise you could create your own application for scripting using SMO.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de|||Hum... well, I have been using SQL express since a couple of weeks now, whilst studying databindings. I have already developed some applications using access or mysql so I'm completely noob to Sql stuff.
Thank you anyway man, I'll have a look at that tool.
Cheers,
sfabriz|||
There are a couple of ways you could go here but one method is to delete all from the tables and reset the Identity keys.
Here is the command to reset the Identity field to 30
USE AdventureWorks;GO
DBCC CHECKIDENT ('HumanResources.Employee', RESEED, 30)
GOI would do a search in the books online for DBCC CHECKIDENT|||This is all I was asking for, thank you very much.
sfabrizsql
No comments:
Post a Comment