Upload .db file to Azure SQL - sql

I have a .db file, with a bunch of tables and data (and a few one to many relationships), instead of rewriting everything, is there a way for me to just upload this database directly to Azure SQL?

My suggestion is to install SQL Server Developer Edition on your laptop or local computer and import those database files to that SQL instance as explained here, if they are Dbase files.
Once you have imported the .dbf files to the local SQL Server instance, use SQL Server Management Studio to deploy the database to Azure as shown here and here, or you can use Data Migration Assistant to migrate to Azure as explained here.

Related

Moving SQL Data into Azure SQL PaaS

I have a database in the SQL Server installed on Azure VM. DB Size is 2 GB.
How and what is the best approach to move all data into Azure SQL PAAS Service?
While the method posted by #Harris Xu is absolutely correct, I am adding the issues which I faced when I migrated my 500+ GB SQL Server DB from Azure VM to PaaS using .bacpac method.
Azure SQL DB is in a away limited when compared to On-prim SQL Server or SQL Server on VM's.
You will not face these issues while creating the .bacpac file but when you try to import, it might give some of the following compatibility issues.
Master Keys , Symmetric Keys, Service Queues and certificates cannot
be migrated to cloud. Drop them before preparing bacpac.
Drop orphaned Users.
If you are using XP_CMDSHELL, Trace Flags, DBCC commands or column store indexes, you got to remove them too.
Cross DB Queries are not allowed on Azure SQL DB. Remove all occurrences of ..
If you are calling an API from your stored proc then that too is not possible in Azure SQL DB. As a workaround you can use Logic Apps on Azure.
Moreover, Microsoft Migration assistant can help you find compatibility issues before hand too. You can download it here.
NOTE : This no way the full list of issues, I faced them because I was using all above features, if you are not using them you will not face them.
SQL Migration using data-tier application export/import (BACPAC)
The BACPAC file encapsulates the database schema as well as the data stored in a database application that can be simple imported to an Azure SQL Database.
Workloads using the source database need to be taken offline during the export process to ensure that the exported BACPAC file contains all data in a complete and consistent state.
Export to bacpac file in SQL Server Management Studio (SSMS)
You can follow this post.
Open and connect database file in SQL Server Management Studio (SSMS).
To export a database file, right click on the name of the database. In the context menu, select Tasks > Export Data-tier Application.
The option will open the wizard. Click Next> Introduction page and go to the Export Settings.
Import a bacpac file to Azure SQL
After you connect to your Azure sql, go to Object Explorer pane, right click the database, and select Import Data-tier.
The option will open the wizard. Click Next> Introduction page and go to the Import Settings.
The Import settings are requested to the bacpac file to import.

Is it possible to restore a SQL Server database in Azure?

I have a backup of a SQL Server 2008 database. I'd like to restore it as an Azure SQL Server database. Is this possible?
P.S. I've seen a couple of questions to this effect from 2014. Is it possible today?
AFAIK, no it's not possible.
The Unsupported in SQL Azure doco https://azure.microsoft.com/en-us/documentation/articles/sql-database-transact-sql-information/ directs you to BOL and RESTORE shows it's not available in SQL Azure.
https://msdn.microsoft.com/en-us/library/ms186858.aspx
Are you able to restore the backup to an instance of SQL 2008 on-premises/locally first? If so you can then use management studio to Export the data and schema as a BACPAC or DACPAC file (export data tier application), which can then be imported into an Azure database using the Import data tier application. You can also use the Taks -> Generate Scripts option from the database node in the management studio, ensure you check on include schema and data - then the SQL files can be executed against your SQL Azure instance as well.
There are some features which aren't available in SQL Azure that are on the server product, but the import will tell you about those if there are any - things like FILESTREAM aren't supported in Azure. Here is the link to take you through steps to migrate from SQL server to SQL Azure - and here are the differences in supported features between the two.
I have some production databases in Azure and frequently download them as data tier apps, import them into a local instance of SQL Server to do some debugging or testing, its a painless process.

Importing XML files to Azure SQL Database

I have a large amount of XML files that I transfer via ftp to an azure website folder on a daily basis. I currently use c# to transfer the data to azure sql server tables. However, it is extremely slow.
Is there a way I can run an Azure SQL job to bulk import these files and if so, how do I access the files in the web apps folder?
I know how to do this on a standard SQL server with XML files residing on a share drive but am unsure how to do this in azure.
Currently, we do not support any T-SQL interface to read files from blob store or container. So you have to push the data from outside of SQL Server.
One option is to use Azure Automation to run your code periodically or based on a schedule. See post below on how to use Azure Automation:
http://azure.microsoft.com/en-us/documentation/articles/automation-manage-sql-database/

Azure Bacpac file Restore Error

I do the daily bacpac file backup from Azure database using RedGate Azure Backup tool.
Until 31st of May, All my Bacpac files can restore to Local SQL2008R2 database using DAC Client Tool.
Starting from 1st of June, I got error like:
Failure Creating schema objects in database
'XXXXX' System.Data.SqlClient.SqlException (0x80131904): Cannot
find the object "dbo.XXXX" because it does not exist or you do not have per
missions.
When I check it table still exist in DB.Also No idea for this.
Is there anyone face that kind of missing table, invalid Column.. etc
RedGate Azure Backup is deprecated now. The DAC Client Tool (DacCli.exe) has been integrated into SSMS 2012 and SSDT. You could try updating your DAC Client Tool to the latest version (1.6 from 1.2)
SSMS 2012 Data Tools now allow you to Import Data-tier Applications. Take a look at the Data-Tier Application Framework Feature in SQL 2012 downloads. View this MSDN article for reference.
I use the free utility SQL Backup and FTP to backup Azure SQL Databases to a local .bacpac file. The free version allows you to backup up to 2 different databases and then the paid versions are very reasonable (i.e. Professional version is $70 or so).
http://sqlbackupandftp.com/
It actually runs on a schedule for me, automatically emails me the results of the backup and stores it on my Google Drive (even with the free version - I just have it store the timestamped backups in the file folder of my Google drive).
The procedure I use to restore it to a local database is:
Back up SQL Azure to .bacpac file
Login to local database server as sa
Right-click Databases
Click Import Data-Tier Application
Select .bacpac file either from Azure or local disk
Enter the name and the locations to store the data and log files
If necessary, set the original database to single user mode and delete it
If necessary, rename restored database to original database name
Note: Must use SQL Server 2012 (or later) management tools

Why cant I create a database with mdf file?

I have a feature in visual studio which I have never really understood.
I am able to 'right-click' on the App_Data folder and then I am able to select 'Sql Server Database'. I dont really understand how I can create a db using just an mdf file? I thought the sql service was responsible for manipulating these files? And that you have to create the db using the 'sql management studio' interface?
Im confised as to how we can essentially just have a lone file and run a db from it for a website?
You're application is still connecting through the SQL Server service but it can instruct the service to attach to a specific mdf file at runtime through a connection string. e.g.:
"Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;"
All SQL Server databases are represented as one (or more) .mdf files and usually .ldf files as well (ldf is the log file, mdf is the data file.) An .mdf file is a file but it is highly structured and maintained by SQL Server. The way SQL Server uses this file is very different from serving up CSV data, as a simple example. SQL Server breaks the file into pages and serves the requests for reads and writes via this paging system. It is indeed like a file system within a file system. If you think about it it does all make sense. The data has to get persisted to disk and that disk persistence has to come in the form of a file or files.
When you installed Visual Studio you also installed SQL Server Express. This gives you the ability to create and use SQL Server databases.
If you were to deploy your application you would then also need to have a SQL Server (Express) install on the web-server you were using (at least because you don't want to use your development database server in production).