Unix Technical Forum

Proper scripting of table with belongings

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 ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 03:48 PM
Matik
 
Posts: n/a
Default Proper scripting of table with belongings

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 03:48 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Proper scripting of table with belongings

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:30 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com