I have on my azure portal 2 sql databases, which for demonstration purpose I call them database one and database-two
Using python ODBC Driver 17, I am able to connect to database one and create a simple table. So far no big issues.
Where I am facing a problem, is when I try to make a backup of database-one I am getting this error:
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for sql Server][SQL Server]Statment 'BACKUP DATABASE' is not supported in this version of SQL Server. (40510) (SQLExecDirectW)"
the line of code I am using to achieve this is as follow:
cursor.execute("BACKUP DATABASE [database-one] TO DISK = N'./backup.bak'")
Is there any solution how I can run the backup from pyodbc?
Azure Sql Not support to generate '.bak' format backup file.
Azure Sql Not support to take back up of Azure SQL Database using Backup database command.
If you want to achieve the backup of Azure sql
you have to import the BACPAC File to a local SQL Server which supports importing BACPAC File.
After a new User Database will be created.
Then you could generate a '.bak' format file from the local SQL Server.
Please Refer: How to create BAK file from azure sql db
For more info: https://learn.microsoft.com/en-us/azure/azure-sql/database/database-import?tabs=azure-powershell
Related
I am migrating my databases from Azure SQL VM to Azure SQL DB using offline migration but while migrating I am getting a error i.e " Microsoft.Azure.Management.DataMigration.Models.ODataError"
I am using powershell script to migrate the database.
I don't know what is wrong in this and why am getting this error.
I have attached the error screenshot herein.
As per this thread on Microsoft Q&A, the issue could be in relation to different collation on the source and destination DB's. I recommend you to raise a support ticket if possible.
Alternatively, you can use SQL Server Management Studio(SSMS) to migrate the Database.
Install the SSMS in your local machine and connect to the Azure SQL VM by following connect to SQL server steps in the tutorial.
Once you are connected with the server, follow the steps as mentioned in this thread to migrate the database to Azure SQL Database.
I was given a SQL Server bacpac file to restore a database on a Ubuntu 20.x instance.
I thought I would use this command to restore the file:
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password123!" -Q "RESTORE DATABASE [demodb] FROM DISK = N'/var/opt/mssql/backup/mssql-latest.bacpac' WITH FILE = 1, NOUNLOAD, REPLACE, NORECOVERY, STATS = 5"
Though the error it fed me was:
Msg 3241, Level 16, State 1, Server 6f604ce9f741, Line 1
The media family on device '/var/opt/mssql/backup/mssql-latest.bacpac' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Server 6f604ce9f741, Line 1
RESTORE DATABASE is terminating abnormally.
And when looking into this more via google searches it seems to be related to an older version of SQL Server bacpac being used with a newer version of SQL Server.
I am currently running SQL Server 2019 Express, thinking that this would work.
How can I find out which version I need to use without downloading every version of SQL Server? Similarly, How do I know if I need to use Express or Developer, or any of the other versions of SQL Server. I thought Express would be ideal because I think it is lightweight.
Real issue here is, you are trying to restore a .BACPAC file using "RESTORE DATABASE" command which will obviously fail as "RESTORE DATABASE" command is used to restore .BAK file not .BACPAC file.
You got to use SQLPackage utility to restore a BACPAC file. Details are provided here.
BACPAC is basically ZIP file. You can change the extension of file to zip file and extract it. You can see the version of the SQL Server.
Reference article on editing bacpac file
You can open the Origin.xml for the SQL Server version of the BACPAC.
Also, to answer your question of SQL Server Express Vs SQL Server Developer. SQL Server Express is limited feature set and SQL Server Developer is with full feature set as SQL Server Enterprise edition. But, you can use SQL Server Developer only for the development purposes and not in production. Express edition is having some limitation on storage and features. If it is not satisfying, you can go for Developer edition and later upgrade, when you go for production.
The different editions of SQL Server and differences among them
I have created one database from ssms 2017 version on azure sql server with .bacpac file, but when I am trying to access it from azure portal it is not showing under azure sql server instance. But when I am login into that instance with SSMS it is showing that database. Need help on this, can anyone face this problem.
regards
Sandy
I did the same operation successfully. I imported a new database with a BACPAC file to my Azure SQL Database. Please reference my steps:
connect to my Azure SQL Database instance with SSMS, right-click Databsse, choose Import Data-tire Application. I import the DB2 database from my BACPAC files.
Import Settings.
Complete the import. After the import job finished, we can see the database DB2.
Check the database on Azure Portal. Login my portal, choose the SQL server which our database instance host on in home page.
Click in the SQL server and we can find the new database DB2.
My SSMS version is the latest v17.9.1.
Hope this helps.
From azure portal I raise ticket regarding this issue, they solved my problem. Added my Azure Sql database to my subscription. During .bacpac file restore some issue occur due to which it wasn't show on portal. Also I am able to delete that datbase from SSMS generated delete script for database.
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.
I want to export database from local computer to database server in SQL Server 2005.
How can I restore database without having access to file system of database server
You can use SQL Server's built-in backup and restore functions.
Make a backup of your local database, and write it on some network share (can be anywhere in the network, doesn't have to be on the database server):
BACKUP DATABASE MyDatabase TO DISK = '\\Servername\Share\MyBackup.bak'
Then, you can restore the database on the database server, reading the backup directly from the network share:
RESTORE DATABASE MyDatabase FROM DISK = '\\Servername\Share\MyBackup.bak'
Note that you have to everything in T-SQL to be able to read and write directly to network shares!
(You can also backup and restore databases from the GUI in SQL Server Management Studio, but you can only use local folders there)
Your situation is, you want to copy the database from your local to remote database server but you do have access to the remote machine thats why you cannot use a restore or attach database function.
Solution:
For me the best thing to do is generate a script that will include the schema and the data of the database. This will serve as a script backup of your local database which can be run to any sql servers that you wanted. Sql Server 2008 already have the interface for this but for Sql Server 2005 you will need to have Sql Publishing Wizard.
You can download it from here: (remove spaces)
http: //www.codeplex.com/sqlhost/Wiki /View.aspx?title=Database%20Publishing%20Wizard
To create a script you can do this:
Command to run which will create schema and database:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql”
Command to run which will create schema:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -schemaonly
Command to run which will create data:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -dataonly
For more details please read...(Remove Spaces)
http: //blog.sqlauthority.com/2007/11/16/ sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/
This worked for me a lot of times.
You will need access to the file system of the database server.
You have to detach the database from your local server and then copy the related .mdf and .ldf files to the target database server and then attach the files in the SQL server management studio of that database server.