Attaching a database

  • Let me just start of by saying i am new to SQL so go easy on me.

    I am just after two simple scripts.

    1st = to attach a sql database e.g(c:\temp\test.mdf) to sql2005 express

    2nd = to dettach a sql database e.g(c:\temp\test.mdf) to sql2005 express

    any help would be very helpful

    Thankyou.

  • USE [master]

    GO

    CREATE DATABASE [test] ON

    ( FILENAME = N'c:\temp\test.mdf' ),

    ( FILENAME = N'c:\temp\test.ldf' )

    FOR ATTACH ;

    GO

    Should work for Attaching a db.

    Prasad Bhogadi
    www.inforaise.com

  • Prasad Bhogadi (4/8/2008)


    USE [master]

    GO

    CREATE DATABASE [test] ON

    ( FILENAME = N'c:\temp\test.mdf' ),

    ( FILENAME = N'c:\temp\test.ldf' )

    FOR ATTACH ;

    GO

    Should work for Attaching a db.

    Thanks Prasad

    sorry for being simple but what do you run this through? e.g. (OSQL)

  • You could use osql as well as Management Studio (a graphical fronted, which if you do not have installed can install for SQL Server Express from http://www.microsoft.com/downloads/details.aspx?FamilyID=c243a5ae-4bd1-4e3d-94b8-5a0f62bf7796&displaylang=en)

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply