sp_attach script?

sp_attach script?

Post by Allan Mitche » Sun, 31 Mar 2002 16:47:05



osql would be a good thing to use here.

Look it up in BOL

allan


>I want to be able to install SQL DB files (MDF-LDF) onto a
>machine, no problem there, but then automate the
>attachmentment to the server.

>I am familiar with using "sp_attach" inside Query
>Analyzer, but how can I get the same script to run from
>out side EM or QA, maybe a VB script?  Any ideas are
>greatly appreciated!

Allan Mitchell
-----------------------
www.allisonmitchell.com
Visit the site for DMO and DTS code and articles
 
 
 

sp_attach script?

Post by Jim Ehler » Mon, 01 Apr 2002 12:00:14


Thanks, I will look in to it.  I was thinking OSQL.  I
just am not yet sure how I would call the script from an
installation routine such as Wise or Install Shield?

>-----Original Message-----
>osql would be a good thing to use here.

>Look it up in BOL

>allan

>On Fri, 29 Mar 2002 18:33:45 -0800, "Jim"

>>I want to be able to install SQL DB files (MDF-LDF) onto
a
>>machine, no problem there, but then automate the
>>attachmentment to the server.

>>I am familiar with using "sp_attach" inside Query
>>Analyzer, but how can I get the same script to run from
>>out side EM or QA, maybe a VB script?  Any ideas are
>>greatly appreciated!

>Allan Mitchell
>-----------------------
>www.allisonmitchell.com
>Visit the site for DMO and DTS code and articles
>.


 
 
 

sp_attach script?

Post by Eric Weinraub[M » Thu, 04 Apr 2002 09:20:18


There are some possibilities to do by using information contained within
the system tables of the origination server prior to detaching the database.

Assuming that this is SQL 2K.  You will notice that the sysaltfiles table
in the master db contains both the name of the database and the database
(MDF) and log (LDF) files.  You could easily use these  columns to build
strings that would create the sp_attach_db statements.  Simply save them to
a file and run them on the new server.  Of course, you may have to change
the paths slightly or make the change when you build the strings.

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure?  For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

 
 
 

1. SP_attach and Master.mdf

Need some more help with restoring an SQL7 server DB files.

1. The previous MASTER.MDF was 300MB, and the defualt
installed Master.MDF is around 9MB.  I'm wondering if or
should I import the previous Master as it must hold some
critical information that the other DB's rely on.  Am I
out to lunch on this?  I should import this one first
right?

2.  One of the db's is 49MB, however the associated LDF is
3GB!!  Can I blow that LDF away and not import it?  My
understanding is that by defualt, the LDF begins with 1/4
of the MDF size.  How did it get out of hand??

3.  If I use the SP_Attach, and bring in the database into
a temp DB, then use the DTS to import the new temp DB, I
can blow the attached files and temp DB away and recover
some disk space?  Thoughts and help please.  

Caution--Idiot at work!

Tanks--Wayne
INSERT ..., etc.) which

2. SQL Server is unavailable or does not exist

3. sp_attached db doesn't show up in ODBC database list

4. Execution time of stored procedure

5. How to use sp_attach/detach or backup/restore from one server to another server

6. Slow Query: Followup

7. Backup vs sp_attach

8. WITH ENCRYPTION

9. sp_attach error 9004

10. sp_attach and multiple file attachment problems

11. Can a DB be sp_attach'd under a different name

12. sp_attach, sp_detach

13. sp_attach SQL-Server 7.0 files to SQL-Server 2000