How to add server level triggers - sql-server

I am new to SQL Azure and want to add a server level trigger like in normal (non-Azure) SQL Server. How can I achieve this?

According to Azure SQL Database Transact-SQL differences from Microsoft:
Transact-SQL syntax not supported in SQL Database
Triggers: Server-scoped or logon triggers
So it seems you cannot create sever-level triggers on SQL in Azure.
This was also the first result on Google when I searched for sql server azure server level triggers, so you need to try doing at least some research yourself before posting in the future.

Related

Azure SQL Automation stored procedures

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.

Deploy database to Azure SQL fails, sp_MSforeachtable not found

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)"

How to migrate a database that uses master db stored procedures to 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.

table access security - ms sql server azure

I read somewhere that "table access level security" does not exist for sql server azure. Unfortunately, I cannot find the blog/page anymore. Can experts please clarify this, ideally with some evidence? Thanks.
You have heard it wrong probably; It's allowed. Per MSDN Documentation On: SQL Server Feature Limitations (Azure SQL Database)
The limitation list doesn't include table level permission security.
Again, per MSDN Documentation On: GRANT Object Permissions it says
Applies to: SQL Server (SQL Server 2008 through current version),
Azure SQL Database.
Which apparently implies that, you can grant table level access permission in SQL Azure as well.

Can you configure SQL Server 2008 Auditing to keep the audit data on a database other than the one being audited?

We are planning on using the new auditing feature in SQL Server 2008. Is there a way to configure the auditing component to insert audit data to a separate database?
I don't believe so. It's to-file (rolling log) or to event viewer. This is a good reference: http://www.sqldbatips.com/showarticle.asp?ID=133

Resources