dbTalk Databases Forums  

Proper scripting of table with belongings

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Proper scripting of table with belongings in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Matik
 
Posts: n/a

Default Proper scripting of table with belongings - 02-07-2008 , 11:22 AM






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

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Proper scripting of table with belongings - 02-07-2008 , 04:23 PM






Matik (marzec (AT) sauron (DOT) xo.pl) writes:
Quote:
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 (AT) sommarskog (DOT) 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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.