Wednesday, February 15, 2012

Exporting SQL db from Visual Studio?

Hi
I have a Visual Studio website with an mdf file in the App_Data folder. I'm
trying to move my site to my webhost, and I think the only way it will work
is for me to "backup" the database to .bak files, and then import it.
Is it possible to backup/export the database in VS, or do I need to install
SQL Management Studio and connect to the instance running inside VS?
Thanks,
Dan
Your databases are not running under VS. SQL Server Express Edition or
Developer Edition (if your VS is Pro Ed.) would be installed when you
install VS 2005. So your databases are already being stored in a SQL Server
instance.
You can easily manage your databases using SQL Server Management Studio.
Ekrem ?nsoy
"musosdev" <musoswire@.community.nospam> wrote in message
news:EFC0CEB9-E133-44C3-A927-99F2B1A95215@.microsoft.com...
> Hi
> I have a Visual Studio website with an mdf file in the App_Data folder.
> I'm
> trying to move my site to my webhost, and I think the only way it will
> work
> is for me to "backup" the database to .bak files, and then import it.
> Is it possible to backup/export the database in VS, or do I need to
> install
> SQL Management Studio and connect to the instance running inside VS?
> Thanks,
>
> Dan
|||Hi Dan,
From your description, I understand that you would like to know if it is
possible to backup/export your database in Visual Studio.
If I have misunderstood, please let me know.
In Visual Studio 2005, it does not provide GUI feature for database backup
and restore, however you can create a T-SQL backup statement and execute it
in it. You may refer to the following steps:
1. Click View menu, select "Server Explorer", right click "Data
Connections", click "Add Connection...", and select your database server
and database;
2. Click Data menu, select "New Query", and directly click Close button in
the "Add Table" window;
3. Input "BACKUP DATABASE <database name> TO DISK='<backup path>'" to the
SQL window and execute it.
Also, you can use the utility osql.exe/sqlcmd.exe from command line to
backup your database. For example:
[osql utility - included in MDAC installed with Windows OS ]
osql -S <server name>\<instance name> -E
1> BACKUP DATABASE <database name> TO DISK='backup path'
2> Go
1> quit
[sqlcmd utility - included in SQL Native Client]
sqlcmd -S <server name>\<instance name> -E
1> BACKUP DATABASE <database name> TO DISK='backup path'
2> Go
1> quit
Hope this helps. If you have any other questions or concerns, please feel
free to let me know. It is my pleasure to be of assistance.
Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====
|||Hi guys
Thank you both for your replies.
Having installed SQL MS and used it on my main server, I thought I'd go for
that as I know that quite well. So I actually downloaded and installed SQL
Server Management Studio Express.
This installed ok, saw the .\SQLEXPRESS instance, and allows me to connect
to it.
However, the database my website uses is not listed under DATABASES.
Any ideas why that might be, and how to make it appear?!
Thanks
Dan
"Charles Wang[MSFT]" wrote:

> Hi Dan,
> From your description, I understand that you would like to know if it is
> possible to backup/export your database in Visual Studio.
> If I have misunderstood, please let me know.
> In Visual Studio 2005, it does not provide GUI feature for database backup
> and restore, however you can create a T-SQL backup statement and execute it
> in it. You may refer to the following steps:
> 1. Click View menu, select "Server Explorer", right click "Data
> Connections", click "Add Connection...", and select your database server
> and database;
> 2. Click Data menu, select "New Query", and directly click Close button in
> the "Add Table" window;
> 3. Input "BACKUP DATABASE <database name> TO DISK='<backup path>'" to the
> SQL window and execute it.
> Also, you can use the utility osql.exe/sqlcmd.exe from command line to
> backup your database. For example:
> [osql utility - included in MDAC installed with Windows OS ]
> osql -S <server name>\<instance name> -E
> 1> BACKUP DATABASE <database name> TO DISK='backup path'
> 2> Go
> 1> quit
> [sqlcmd utility - included in SQL Native Client]
> sqlcmd -S <server name>\<instance name> -E
> 1> BACKUP DATABASE <database name> TO DISK='backup path'
> 2> Go
> 1> quit
> Hope this helps. If you have any other questions or concerns, please feel
> free to let me know. It is my pleasure to be of assistance.
> Best regards,
> Charles Wang
> Microsoft Online Community Support
> ================================================== ===
> When responding to posts, please "Reply to Group" via
> your newsreader so that others may learn and benefit
> from this issue.
> ================================================== ====
> This posting is provided "AS IS" with no warranties, and confers no rights.
> ================================================== ====
>
|||Hello,
Is your database that your website uses located on your local hard drives or
is it located on another server?
If it's on your local hard drive, then you need to find that database's mdf
file and attach it to your current running SQL Server instance to manage it
using SSMSE.
If it's located on a remote server then you need to know its IP and add it
as an Alias using SQL Server Configuration Manager. So, you'd be able to
connect to that instance (so your database) using your SSMSE and using that
Alias.
Ekrem ?nsoy
"musosdev" <musoswire@.community.nospam> wrote in message
news:6D0F8324-F122-4644-93A7-7FF819D57D02@.microsoft.com...[vbcol=seagreen]
> Hi guys
> Thank you both for your replies.
> Having installed SQL MS and used it on my main server, I thought I'd go
> for
> that as I know that quite well. So I actually downloaded and installed SQL
> Server Management Studio Express.
> This installed ok, saw the .\SQLEXPRESS instance, and allows me to connect
> to it.
> However, the database my website uses is not listed under DATABASES.
> Any ideas why that might be, and how to make it appear?!
> Thanks
>
> Dan
>
> "Charles Wang[MSFT]" wrote:
|||Hi Dan,
I am not an expert regarding ASP.NET, however from my research, your web
application is using SQL Server 2005 Express Edition User Instances:
SQL Server 2005 Express Edition User Instances
http://msdn2.microsoft.com/en-us/library/bb264564.aspx
I performed a simple test at my side. You can easily create a database in a
web application under the App_Data folder. You can easily manage it in
Visual Studio. When you double click the .mdf file, the database will be
displayed under the Data Connections in Server Explorer.
The database created in user instance will not be displayed in SSMS by
default, however you can refer to the section "Connecting to User Instances
from Other Clients" in the above article or the following article for
connecting to the user instance in SSMSE:
How to: Connect to a User Instance
http://msdn2.microsoft.com/en-us/library/aa337276.aspx
I looked through your original post carefully and I thought that your real
concern was that you would like to move your database to another webhost
together with your web application. However what is the matter if you
directly copy all the database files together with your website? or you can
use "Copy Website" or "Publish Website" to your remote server in Visual
Studio 2005? Make sure that you have detached the database in Visual Studio
2005 before you perform the progress.
If you have any other questions or concerns, please feel free to let me
know. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

No comments:

Post a Comment