Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 copy table structure including index

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2005-05-29 : 08:22:59
How to copy table structure only including index ?

raclede
Posting Yak Master

180 Posts

Posted - 2005-05-29 : 20:08:11
Well in mmc right click the table -> generate SQL Script -> paste in QA

"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside. "

raclede
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-05-30 : 00:42:35
make sure you select the option to generate indexes. that is an easy one to miss.


-ec
Go to Top of Page

raclede
Posting Yak Master

180 Posts

Posted - 2005-05-30 : 00:43:27
yup.. I've forgot to mention.. thnx.. eyechart

"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside. "

raclede
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2005-05-31 : 01:42:44
1) Go to SourceSafe or whichever tool you are uising for your source code control system.

2) Check out the script that contains the DDL.

3) Run the...

(Nevermind; do whatever you like.)


HTH

=================================================================
The surest way to corrupt a youth is to instruct him to hold in higher esteem those who think alike than those who think differently. -Friedrich Nietzsche, philosopher (1844-1900)

Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-05-31 : 02:16:04
quote:
Originally posted by Bustaz Kool

1) Go to SourceSafe or whichever tool you are uising for your source code control system.

2) Check out the script that contains the DDL.

3) Run the...

(Nevermind; do whatever you like.)




yeah right. there are probably 7 people on this site who use source safe with SQL 2K for all their databases. There is so much manual effort involved to make the client tools work with source safe, that is really isn't worth it in my view.

You still need to know how to script the objects out of the database in order to put them in the source control system, which is what the original poster had asked.



-ec
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2005-05-31 : 16:03:08
Every object I create is created using scripts. The scripts are either developed by hand or through a code generation tool. A lot of the tedium of developing the scripts by hand can be removed by the use of templates in Query Analyzer.

There are third party tools (e.g., Apex SQL Edit, et al) that already have SourceSafe integrated so there is less of a manual burden than there used to be. Frankly, the fact that Query Analyzer doesn't have this level of integration is a serious, glaring and on-going problem.

I never use Enterprise Manager to create objects. The scripts that it produces are hideous and incomplete.

Not having your database objects scripted and having the scripts in some form of source code control, SourceSafe or otherwise, is tantamount to professional misconduct. How else are you gong to be able to reproduce a consistent environment and track the historical changes?

I'd be curious to know other people's take on this and how do other people handle these issues?



HTH

=================================================================
The surest way to corrupt a youth is to instruct him to hold in higher esteem those who think alike than those who think differently. -Friedrich Nietzsche, philosopher (1844-1900)

Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-05-31 : 17:49:44
quote:
Originally posted by Bustaz Kool

Every object I create is created using scripts. The scripts are either developed by hand or through a code generation tool. A lot of the tedium of developing the scripts by hand can be removed by the use of templates in Query Analyzer.



If I just had to take care of databases of my own creation it would be different. However, I have 3rd party apps to worry about too. We have 30+ instances with over 300 databases to deal with.

Again, this really wasn't what the guy asked when the question was asked. It was how to generate the DDL from an existing object.


-ec
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2005-05-31 : 19:37:44
>>> Again, this really wasn't what the guy asked when the question was asked. It was how to generate the DDL from an existing object.
<<<

I know. I really just wanted him to see that there was another approach that was, perhaps, outside his field of view. If you start with the premise that a table exists and that you then need to create a script for it, then , of course, how to create the script is a perfectly logical question. If, OTOH, you begin with the premise that a script already exists that created the table, then the steps involved in re-creating the table and its index are entirely different and the problem solves itself.

Just presenting a viewpoint; feel free to ignore it. You won't be the first ;-)

HTH

=================================================================
The surest way to corrupt a youth is to instruct him to hold in higher esteem those who think alike than those who think differently. -Friedrich Nietzsche, philosopher (1844-1900)

Go to Top of Page
   

- Advertisement -