The following SQL script has been tested and known to work under SQL
Server 2008 Developer Edition.
Assumptions:
1. The database is named HelloFluentNHibernate
2. The schema owner is dbo.
-- Cleans out all the tables to allow the example to run again
-- Author: Fred Morrison
USE [HelloFluentNHibernate]
GO
-- First, turn off all Foreign Key enforcement
ALTER TABLE dbo.[StoreProduct]
NOCHECK CONSTRAINT ALL;
GO
ALTER TABLE dbo.[Store]
NOCHECK CONSTRAINT ALL;
GO
ALTER TABLE dbo.[Product]
NOCHECK CONSTRAINT ALL;
GO
ALTER TABLE dbo.[Employee]
NOCHECK CONSTRAINT ALL;
GO
TRUNCATE TABLE dbo.[StoreProduct];
GO
TRUNCATE TABLE dbo.[Employee];
GO
--TRUNCATE TABLE dbo.[Store]; // can't do this easily, even in SQL
Server 2008 - what a pain!
DELETE FROM dbo.[Store];
GO
-- Since DELETE does not reset the Identity column, do that now.
DBCC CHECKIDENT ("dbo.[Store]", RESEED, 0);
GO
--TRUNCATE TABLE dbo.[Product]; -- DRI error if you try this, even if
FK's are disabled
DELETE FROM dbo.[Product];
GO
-- Since DELETE does not reset the Identity column, do that now.
DBCC CHECKIDENT ("dbo.[Product]", RESEED, 0);
GO
-- Last, turn on all Foreign Key enforcement
ALTER TABLE dbo.[Product]
CHECK CONSTRAINT ALL;
GO
ALTER TABLE dbo.[Store]
CHECK CONSTRAINT ALL;
GO
ALTER TABLE dbo.[StoreProduct]
CHECK CONSTRAINT ALL;
GO
ALTER TABLE dbo.[Employee]
CHECK CONSTRAINT ALL;
GO
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---