Restore SQL Server database from a script - sql-server

I have a database stored on SQL Server with my web site at a regular windows hosting solution. I need to migrate to Azure.
The only backup mean I have is to use SQL Server Management Studio and do a Task -> Generate scripts that saves schema and data in a sql file. I did it and I got a 260Mb file.
My question is about importing that to Azure. Can I do it in Mngt Studio too? How?
Thanks

If you have exported it all to scripts, yes, you can run them against your SQL Database. However, before you do that I'd suggest looking at https://azure.microsoft.com/en-us/documentation/articles/sql-database-cloud-migrate/. It might shed some light on other options that will include verifying compatibility. The BacPac method might be better than the scripts.
To answer the specific question of using SSMS with Azure SQL DB, this article https://azure.microsoft.com/en-us/documentation/articles/sql-database-manage-azure-ssms/ shows how to make the connection.

Related

Browsing an Entity Framework code-first database + Azure Dev Fabric

I have a database created using the code-first approach against SQL Server Express. I'm trying to view the database in Management Studio, but cannot find the database. VS Database Explorer also cannot seem to find it.
I've searched about but cannot find any reference to what I'm after. Is it possible to browse a database running in the dev fabric?
Usually if we create a new database in Visual Studio, it will give us a database file, but it won’t register the database in SQL Server Management Studio. So please manually attach the database file to SQL Server Management Studio. First please find the database file, normally it is under the AppData folder of our project. Then I would like to suggest you to check http://msdn.microsoft.com/en-us/library/ms190209.aspx for instructions on how to attach the database.
Best Regards,
Ming Xu.
Take a look at Scott Gu's blog post on EF Code First and DB Generation: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
The Azure Dev Fabric has nothing to do with the DB layer, the connection string handles all this for you i.e. when you deploy to SQL Azure your DB will go there, the only thing that needs changed is the connection string...from localhost (Dev Machine) to SQL Azure connectionn string
HTH

Deploying .bak file from SQL Server in Mac

Ok, I know this may sound stupid but, is there any way to deploy a database from a .bak file exported from SQL Server into any kind of Mac software? If there, which one?
If that is not possible, is there a way that I could deploy that database if I first deploy it into SQL Server and export it, maybe in a different way?
Thanks in advance.
The bak file created by SQL Server is a database backup file, and you will only be able to restore it to a Microsoft SQL Server instance.
If you want to port a MSSQL database to some other RDBMS, your best bet is to use a tool for migrating the data directly from the running MSSQL datbbase to another running RDBMS. Perhaps a third party tool, or you could build an SSIS package to do the migration.
You can create a MySQL database and try the MySQL migration tool.
But just given a .bak file, you will not be able simply to read the file; you will need to extract data from a running database instance.

Transfer SQL Server data to SQL Azure

I have a local database SQL Server 2008 Express and I have tables along with data in them. I want to export those schemas and data to SQL Azure database.
What I have tried in SQL Management Studio is to right-click database (contextual menu) and Tasks->Generate Scripts. But those SQL scripts were only the schema, stored procedures etc and no data is exported at all.
Then I have tried Tasks->Export Data, but there were no appropriate export types. I have seen only Flat File dump and I think SQL Mgmt Studio 2008 R2 does not support importing flat files for SQL Azure.
Is there a nicer way to export data from SQL Server as sql scripts and execute them on a remote server without using any 3rd party tools?
I found that SQL Azure Migration Tool http://sqlazuremw.codeplex.com/
Very handy and useful. Worked for me.
In Tasks/Generate Scripts you can set Script Options/Script Data to be True, which should script out the data as well.
Not free, but SQL Data Compare will let you move data from on-premise to SQL Azure.
You can try SQL Server Import and Export Wizard.
For Detailed steps reg how to do it, check link.
I have worked with it already and it works fine for both Azure and on-premises.
An article that comprehensively explains available options:
http://parasdoshi.com/2011/06/20/solidq-journal-article-migrating-data-into-microsofts-data-platform-sql-azure/
Full disclosure: i work at SolidQ.com

how to upload sql server 2008 database to the production server

hey guys,
i am creating a website for a client, my website is almost complete, now i want to upload the database to the clients production server, but i dont have any hint about how to upload the database to the production server. can anyone please help me with the steps how to upload the sql server 2008 database to the production server, keeping in mind, the production is not the dedicated server, i think i have to run my database script, on the server, but i dont know how to run, will i get the option for the same on the production server, or need to dig for the same on the sql server...
Please help me for this as soon as possible..
Thanks and Regards
Abbas Electricwala
I can think of few methods.
For example,
If you have version controlled database objects in Visual Studio then you can just deploy it to server by specifying production database connection. This MSDN link can help you in that case.
Or,
You can take backup of your current development database and restore it to production server. If you have never worked with backup and restore, read on these MSDN links, for Backup, for Restore. Of course, in normal situation Backup/Restore is not this straight forward but since your system is new and not in use, this should be easy task.
Or,
Script out database objects from current development server and run those scripts to production server (say by using Sql Server Management Studio). Generating scripts is easy but I don't think anyone can explain it step-by-step in few lines. But you can read this MSDN link for detailed information.

Easiest way to copy an entire SQL server Database from a server to local SQL Express

I need to copy an entire database from a SQL Server 2005 on my server over to my local SQL Express in order to run my application for a presentation. What is the fastest/easiest way to get this done?
EDIT: I have very limited access to my server so I don't think I can access the backup file that I could create so that is out.
If the database is not too big, you could use the Database Publishing Wizard.
This is a free tool from Microsoft which creates a complete SQL script of a database for you (not only the tables and stuff, but all data as well).
You can install the tool on your machine, connect to a remote server and let the tool create the script directly on your machine.
You can download the Database Publishing Wizard here.
Apparently the link above doesn't work anymore in 2019.
That's probably because in newer versions of SQL Server Management Studio, the functionality of the Database Publishing Wizard is included out-of-the-box, so there's no need to install it separately.
It's now called the Generate and Publish Scripts Wizard, but it does exactly the same.
You can right click the database -> Tasks -> Generate scripts. Here you can select one, multiple, or all objects. Then in the 'Set Scripting Options' step of the wizard, click Advanced. In here set the property 'Types of Data to script; to Schema and Data.
Having done these steps, make sure you publish to a file. Because only file can handle large amounts of data.
Now you should have all your objects, tables, and data scripted. Now start running the scripts and viola!
Back up the database on the server and then restore it locally in SQL Express.
EDIT: If this is part of your work, surely you can get someone in networks to get you a backup..?
If you can login to both servers (the Express and the 05 Server) using SQL Server Management Studio then you can do a DB Restore from one database to the other. No need for backup files at all.
You can use SSIS's database copy wizard, but it's not quick at all. Is there a DBA there that you can ask for the backup file? That will probably turn out to be the fastest way.
Depending which versions of SQL Server you are using, you might get some mileage out of the SQL Server Database Publishing Wizard from Microsoft. I've had mixed results with this tool in complex environments, but for most simple database scenarios it is a great tool.
An example of a scenario where I ran into difficulties was a DB with multiple distinct schemas, each with their own owner and extreme separation between the tables (don't ask...). As I said, though, most other scenarios have been fine.
Save your database as a sql script
EMS SQL Manager (for example) allows you to backup your database as a script in a .sql file. It is then possible to run this file against any other SQL server. Just update the first line of the script (CREATE DATABASE ....).
You can even fully parameter the script in order to include data from complete or filtered tables.

Resources