March 20, 2008 at 10:50 am
Is there and way to generate a script that can
drop and create all CONSTRAINT 's in the
database.
The reason i need this is that im going to split a
large database into several smaller identical databases,
and need to remove the indexes and constraints
to be manage to delete the data i dont need.
Any ideas ? 🙂
Per S
March 21, 2008 at 7:47 am
You can use sys.all_objects.
select name
from sys.all_objects
where type in (
'c', -- check constraints
'd', -- default constraints
'f' -- foreign keys
)
That will give you a list of all of those objects. Wrap a cursor around it and use it to create a drop command, and you should be good to go.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply