I am trying to publish a SQL Server database using a .dacpac and publish profile to an Azure SQL database. We have been using on premises SQL Server with no problems for quite some time, and now we are evaluating Azure and AWS to see which is best suited for our needs.
We have a SQL Server database project and want to deploy it to Azure SQL database, however it fails to execute the script generated by SSDT. This is because the generated script contains a call to the stored procedure sp_MSforeachtable which does not exist in Azure SQL.
I also have changed the target platform from SQL Server 2016 to Azure SQL V12. I am trying this from Visual Studio 2017's publish profile and from VSTS Release management using Azure SQL database deployment task. An of course by providing the necessary .dacpac and publish.xml files in the task.
I know I can manually add the stored procedure, however it doesn't seem that is what is intended by these publishing/deployment methods. Does anyone have any ideas?
Thanks
sp_MSforeachtable is an undocumented stored procedure in the Master database. This apparently hasn't been ported over to Azure SQL. I believe you'll need to add it manually to the Master database. Once that is done, your DACPAC should work just fine on your own Azure SQL database. I don't see a problem with manually adding sp_MSforeachtable. DACPACs are meant to keep your database in sync, not the Master database.
This feature is not implemented in SQL Database in Azure.
You can find a copy of it at this location: https://gist.github.com/metaskills/893599
Correct, sp_MSforeachtable stored procedure is still missing in Azure SQL, but you can easily create it manually. It is very helpful when you have to rebuild indexes for all tables at once:
exec sp_MSforeachtable #command1="DBCC DBREINDEX ('?', '', 80)"
Related
I have an SQL Server Project as a part of my solution in Visual Studio. It requires that I include some stored procedures that access a different database on the same server. This database is not under our control, nor is it accessible locally to the developers, or in our dev Server. And we cannot import that database because its a few TB in size. The functionality represented by this stored procedures does not need to be called in our dev environment, and only has testable data in the staging and production environments where the other database is accessible.
When we attempt to publish the project to our dev servers, or locally, the publish script generated by VS fails at run time because SQL Server can't generate a stored procedure if it can't resolve the references to the missing database.
I am looking for a way to setup the publishing so that it is selective based on the ##servername variable (ideally, but I am open to other realistic scenarios, such as a way to tell the SQL Server not to try to resolve those references)
Thanks
P.S. I hadnt thought of mentioning it until #larnu's comment, but an additional thorn here is that our dev environment is hosted as an Azure Web app and using an Azure SQL Database server. Even if I created a Mock database for the missing reference, Azure SQL will not allow my stored procedures to see them.
I am migrating on premises SQL server database to Azure PaaS SQL database using Data Migration Tool. I am not using Data Migration Service Instance mechanism to migrate the database as it would require VPN on the corporate network and I do not see any benefit doing that way in my case.
There is one error which I am stuck on and a bit confused. When migrating a stored procedure which use automation stored procedures, I get the following error:
When I run Alter procedure script directly on Azure SQL database , I get this error;
Reference to database and/or server name in 'MASTER..sp_OACreate' is not supported in this version of SQL Server.A few answers to similar question on stackoverflow suggest that Azure SQL does not support automation stored procedures but the Microsoft link has a green tick against Azure SQL which suggest it does; https://learn.microsoft.com/en-us/sql/relational-databases/stored-procedures/ole-automation-sample-script?view=sql-server-2017.
A snippet of the sp is:
Is it true that automation stored procedures are not supported in Azure SQL and if thats hte case then what is hte workaround apart from rewriting the sp?
SQL Azure prevents you from calling server resources. sp_OACreate attempts to create a reference to an OLE object on the server; that's simply not allowed on Azure SQL Database. So you will need to redesign your solution to move this type of logic in a middle-tier of some kind, such as a Web Role in Windows Azure.
We have a sql2k8 database that uses sp_xml_preparedocument, a master db system extended stored procedure, that needs to go to Azure. The migration tools (SSMS2016 wizard) give a validation error: SQL71501 that [dbo].[sp_xml_preparedocument] is a missing reference, when validating the export.
I can't see any way to reference the sp so it can be migrated. Intellisense always shows an error too.
Could you first verify that your code works fine on Azure SQL when you manually execute the scripts? When I execute queries with sp_xml_preparedocument from MSDN on my Azure SQL Database it works fine.
If your code works, then it is a problem in SSMS migration assistant, so in that case you should report bug on SQL Server Connect site, with some minimized repro script, so SQL Server team can fix it.
Use SQL Server 2016 Enterprise with Service Pack 1 (x64) . The SP1 should support Azure DB . The 2012 version of Sql server might do iT.
Having successfully taken a database instance offline using the Management Studio I then attempted it bring that same database back online both using the Management Studio and by executing the following script.
ALTER DATABASE [dbname] SET ONLINE
This results in the following error
User does not have permission to alter database 'dbname', the database does not exist, or the database is not in a state that allows access checks.
Turns out that on RDS you can use the standard SQL script above to take an instance offline, but Amazon require you to execute a stored procedure to bring it back online;
EXEC rdsadmin.dbo.rds_set_database_online dbname
See here for more http://docs.amazonwebservices.com/AmazonRDS/latest/UserGuide/Appendix.SQLServer.CommonDBATasks.html
I would like to ask the experts here on how to script the database objects in SQL Server 2008 Express Edition. When generating scripts, I found out that only tables and triggers are available to be script. But how can the SPs be scripted too?
The problem is that I have a host provider and I wanted the database in my site to have ASP.NET membership framework objects (tables, SPs). It is a big disadvantage because my host does not allow remote access to their SQL Server.
I wanted my site's database to have objects of ASP.NET membership framework. What they allow is SQL scripts using "my little admin" tools.
Any help will be appreciated. If my question is not clear enough, please post a comment so I may revise the question.
Thanks!
See this answer: Script all stored procedures in Management Studio 2005
I wanted my site's database to have
objects of ASP.NET membership
framework.
You can check out aspnet_regsql.exe command, which allows you to create all ASP.NET membership objects (tables/stored procedures) in the target database.
Also check out the Microsoft SQL Server Database Publishing Wizard