Friday, March 9, 2012

Detach and Attach functions in SQL Server 2005

Hi,

I'm trying to port my ASP.NET web application to the production system.

I'm connection to the SQL Server 2005 instance on my hosting server via CTP. I've uploaded the .mdf and .ldf files of my DB via FTP to the hosting server, and then tried to attach using this command:

use master gosp_attach_db'tgp','F:\webspace\disk20\db\TGP.mdf','F:\webspace\disk20\db\TGP_log.ldf' go

but then there is an error (obviously) stating that I don't have permissions to create a database in database master.

I must admit that I'm prettycluelessin this area. My hostingservicesalready created a "place holder" for my database (tgp), but I don't know how to proceed from here in order attach the database files in the production environment. Is this something I can do myself, or must I involve the hosting services?

Thanks,

Alon

sp_attach_db requires the same permissions as CREATE DATABASE - so you're likely not going to be able to do this (if so, let me know who your host is - I could use the free/extra space they'd let me set up *grin*).

You'll either need to contact them and have them hook up your DB, or look into using user-instance/attachable SQL Express functionality.|||

You have two options just backup your database and use management studio to restore your database on the host SQL Server after you have registered the host SQL Server in your management studio. In the backup and restore wizard choose the restore from device option. The other option is try the thread below for Attach database code modify it for your needs and use it. Hope this helps.

http://forums.asp.net/thread/981274.aspx

|||

Thak you for your reply.

I tried to backup/restore, but when I tried to point to the location of the backup file (on the remote server), got the error message that I'm not authorized... I've just sent a request from the hosting firm to handle this.

I have a general question: what are the guidelines when moving from the test/development system to the production system? I couldn't find any article summarizing the process.

Thank you,

Alon

|||You should only use a company that gives you access to management studio so you can use the backup and restore wizard because if you don't backup your database they will charge you to back it up. Here in the US most hosting company will give you the access. Hope this helps.|||

Yep, this helpsSmile [:)]

Alon

No comments:

Post a Comment