[dba-SQLServer] Drop restore indexes

jwcolby jwcolby at colbyconsulting.com
Sun Mar 30 16:20:13 CDT 2008


I do the "script to window" all the time.  It is definitely cool, and I use
it for building append queries from one db / table to another etc.  Using it
I am becoming familiar with SQL syntax, occasionally even "just writing it",
though without a full on editor with all the good stuff it is often just
faster to do the "script to" and cut and paste.  I found where I can script
just the individual indexes and that is good enough.  I will cut and paste
them one after another into a SP which I can then store and run as desired.
So I am "close enough".  I thought that there might be a "script all indexes
to a window" kind of thing but have not found one.

Thanks for the advice though.  The scripting of a table I use a lot to
"build" a similar table in a completely different database. 


John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur
Fuller
Sent: Sunday, March 30, 2008 4:07 PM
To: Discussion concerning MS SQL Server
Subject: Re: [dba-SQLServer] Drop restore indexes

It's built-in, JC. Once you've used the gui to build your table(s) and
indexes, then you can be in MSMS and right-click on either the db or a
selected table and select Script To and then choose your destination for
said script and you will see what click-click-type-click did behind the
scenes.

Not that I ever expect you to write a Cert for MS-SQL, JC, but this is a
good way to learn what's under the covers. And I also add, that virtually
all these IDEs are script languages in disguise. Some of the IDEs make this
readily apparent, such as Visual Studio, DreamWeaver, and others. Click here
and you see the Gui, click there and you see the code behind. In Access it's
a teensy bit more difficult to see, but export a form and then read the code
and you shall see what I mean. They are ALL scripting languages. If you like
the IDE then you like to click and drag and drop etc., but what's going on
under the covers is script-generation.

Back in the initial days of VS.NET there was a popular thread called
"Alternatives to .NET IDE" or similar. People noticed that the IDE cost
money but the framework didn't, and asked if there were an alternative IDE.
The classic answer was, "Yes, NotePad". A sword that cuts both ways: you can
learn the scripting language and write it free in NotePad or any other text
editor, or you can drag and drop and pay money for the privilege.

Last week I met a guy named John McKay who never never never used any of the
gui tools in SQL 2005+. He preferred to type in all the commands and he
could do it way more quickly than I could match, using the gui drag and drop
stuff. Admittedly, he came from a Linux and Oracle background, but he could
type so quickly and knew so precisely what he was doing that it blew me
away. I prefer to see a picture: use the gui interface, add tables and views
and udfs and so on, click this and drag there and I get the job done, but he
knew this stuff so well that he could simply type join this and join that
and presto, done in a fraction of the time it took me.

Back to the topic at hand. Once you've created what you want in the gui,
right-click at the appropriate level and then choose Generate Scripts.
Choose your output destination and click OK and you're there.

A.

On Sun, Mar 30, 2008 at 3:24 PM, Susan Harkins <ssharkins at gmail.com> wrote:

> You're looking for a third party tool as opposed to a dynamic procedure?
>
> Susan H.
> > set up to create the indexes.  I need to have some tool that will 
> > build scripts to recreate the indexes fond on a table and then 
> > remoce the indexes.
> > Once the records are appended, I need to then run the scripts to 
> > rebuild all the saved index scripts.
> >
> > Is there such a tool?
>
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list