Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to attach a DB to SQL Server ?

How to attach a DB to SQL Server ?

Scheduled Pinned Locked Moved ASP.NET
databasequestionsql-servervisual-studiosysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    comp_j
    wrote on last edited by
    #1

    Hello, Im using this following softwares: VS 2008 & Microsoft SQL Server 2005 I want to attach my database to SQL Server. How can I do this(Without using wizard) ? TIA

    A A 2 Replies Last reply
    0
    • C comp_j

      Hello, Im using this following softwares: VS 2008 & Microsoft SQL Server 2005 I want to attach my database to SQL Server. How can I do this(Without using wizard) ? TIA

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      comp_j wrote:

      Im using this following softwares: VS 2008 & Microsoft SQL Server 2005 I want to attach my database to SQL Server. How can I do this(Without using wizard) ?

      How does it related with ASP.NET ? If you have to ask it on General DB Forum.

      comp_j wrote:

      How can I do this(Without using wizard) ?

      Why you want to avoid Wizard ? Do you want to do it programmatically.?

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      C 1 Reply Last reply
      0
      • A Abhijit Jana

        comp_j wrote:

        Im using this following softwares: VS 2008 & Microsoft SQL Server 2005 I want to attach my database to SQL Server. How can I do this(Without using wizard) ?

        How does it related with ASP.NET ? If you have to ask it on General DB Forum.

        comp_j wrote:

        How can I do this(Without using wizard) ?

        Why you want to avoid Wizard ? Do you want to do it programmatically.?

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        C Offline
        C Offline
        comp_j
        wrote on last edited by
        #3

        Abhijit Jana wrote:

        Why you want to avoid Wizard ?

        Because I want to run my project on a system that just have SQL Server engine and .NET Freamwork.

        Abhijit Jana wrote:

        Do you want to do it programmatically.?

        yes, I do.

        1 Reply Last reply
        0
        • C comp_j

          Hello, Im using this following softwares: VS 2008 & Microsoft SQL Server 2005 I want to attach my database to SQL Server. How can I do this(Without using wizard) ? TIA

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Connect to master Database using your .NET object. Then run the stored procedure below :

          EXEC sp_attach_db @dbname = 'dbname',
          @filename1 = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbname.mdf',
          @filename2 = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbname_log.LDF'

          Please replace the path to the existing mdf and ldf files. You can also create using

          CREATE DATABASE [dbname] ON
          ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbname.mdf' ),
          ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbname_log.LDF' )
          FOR ATTACH
          GO

          command Hope you can do this now.

          Abhishek Sur


          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

          **Don't forget to click "Good Answer" if you like to.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups