This is a discussion on Proper scripting of table with belongings within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello all, SQL Server 2000 SP3. Recently, I was preparing a lot of scripts, for all objects in the ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello all, SQL Server 2000 SP3. Recently, I was preparing a lot of scripts, for all objects in the DB. As for SP's, UDF's, VIEW's and triggers it is not a problem, problem occurs when it come to tables. Well, is not a problem, but I would like to save me some job. Using EM, while scripting the tables, it is possible to script them all, to separate file each, or together. It is possible also, to script all FK's, PK's and constrains together with table. The problem is, that using full script, which I want to (with all PK's and FK's), generates an issue with recreating object in other database. This is because, script does not include drop of FK's, and only generates drop of table itself. I think, this is a little different understanding of "include all dependent objects" option by MS and me. What I would like to see, will be a script which contains in order: 1. Droping all FK's, constraint on a table, 2. Droping table, 3. Creating table (with PK's and all extended features) 4. Recreating all FK's and constraints. This order appear to be, in case I will script all my tables to one file ... but, I would prefer to have it scripted each in one file. Is there any way? Best regards Matik |
| ||||
| Matik (marzec@sauron.xo.pl) writes: > This is because, script does not include drop of FK's, and only > generates drop of table itself. > I think, this is a little different understanding of "include all > dependent objects" option by MS and me. > > What I would like to see, will be a script which contains in order: > > 1. Droping all FK's, constraint on a table, > 2. Droping table, > 3. Creating table (with PK's and all extended features) > 4. Recreating all FK's and constraints. > > This order appear to be, in case I will script all my tables to one > file ... but, I would prefer to have it scripted each in one file. I'm not really sure that I understand. If you drop a table, all constraints of that table are droppped as well. Why would you want to drop the constraints explicit first? Or do you mean referencing foreign keys? That's another story. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx |