doveb (5/20/2009)
What a great idea. Thank you for the tip. I did have one question. Are there any additional considerations for items that are schema bound or have foreign keys associated to them?
You can't drop the parent table in a foreign key relationship, but you can drop the child.
You can't drop a table that has a schema-bound view associated with it.
Here's some tests:
CREATE TABLE parent
(
Id INT PRIMARY Key
)
GO
CREATE TABLE child
(
id INT,
parent_id INT REFERENCES parent(id)
)
GO
-- will not work because it is the parent table
DROP TABLE parent;
GO
-- you can drop the child table
DROP TABLE child;
GO
CREATE TABLE child
(
id INT,
parent_id INT REFERENCES parent(id)
)
GO
CREATE VIEW vw_child
WITH SCHEMABINDING
AS
SELECT id, parent_id FROM dbo.child
GO
-- can't drop the table if there is schema bound view
DROP TABLE child;
Go
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question