Does Azure SQL Database support two-phase commit (2PC)? - sql-server

Because I have several unrelated resources to coordinate during commit, I would like to use two-phase commit (2PC) on Azure SQL Database, from Java code (JDBC).
On standard SQL Server, you can do a complex install of some DLL plus some scripts to make available some extended stored procedures, with names like xp_sqljdbc_xa_init or xp_sqljdbc_xa_prepare, that in turn the Microsoft JDBC driver uses to provide the XA semantics of start/end/prepare/commit. But these extended stored procedures aren't available on Azure from what I can see.
Also, by itself, SQL Server doesn't seem to have any PREPARE TRANSACTION primitive, and I don't find one in Azure either.
So how can one do 2PC on Azure?

It's not supported and in many ways incompatible with the benefits and uses cases for cloud computing. There's an excellent blog post by Clemens Vasters that I'd recommend reading and which introduces the service bus feature as a way to accommodate the key aspects of the behavior that you may be looking for.

Related

Can Flyway be used to migrate tables between different databases without migration file?

There are many questions like this on Stack Overflow, but it seems to me that they already have the migration scripts in place. For example, insert and update statements are available, as such, Flyway can just use those scripts to create the tables in the target database and its data.
However, my question is that, what if we don't have those scripts? For example, tables are being created manually or with some other tools and the data are being inserted over the years with the bound application, now we want to switch to a different SQL database. Can Flyway be used as a tool to transfer all the tables and databases only with providing connections?
If the answer is no, how this sort of migration can be done and what are the best practices.
I did a search and went through Flyway documentation but they are all vague and doesn't give you a clear example of that. Some of these tools I found are used for Salesforce but I need a tool/library that possibly can be used in Java using JDBC connection, or other languages such as Python etc, as our databases - for security reasons - cannot be accessed directly and are cloud based.
For your information, we are using a range of databases PostgreSQL, Aurora MySQL, SQL Server.
No, Flyway can't do this sort of thing.
Flyway is a deployment tool. While it certainly can include data movement, as with the deployment of database objects, the scripts supporting data movement have to be completely idempotent or completely isolated in their deployment. Neither of these is lending itself to what you're talking about.
What you're talking about is something like Redgate SQL Compare along with SQL Data Compare. These two would allow you to compare two databases, identify the differences, then generate the necessary scripts. I'm aware of no open source tools that do all that, especially that do all that across multiple data platforms. And that tool only supports SQL Server (there is a second one for Oracle, but no others).
The thing is, if you're allowing deployments to occur using manual processes or 3rd party mechanisms, without going through source control as centralized management of your code, you can't use Flyway anyway. Flyway requires a consistent and stable process wherein it is the thing running deployments. Allowing, or even encouraging, drift through out-of-band deployments will break your Flyway deployments.
DISCLOSURE: I work for Redgate, but we're not the solution you're looking for.

Database Migration Assistant not detecting deprecated features

The documentation for Database Migration Assistant claims that it will identify and flag any "deprecated features". However, this does not seem to be true in the least. I have a SQL Server on-premises database full of features that Microsoft's documentation considers to be deprecated. However, DMA does not detect ANY of these things in an assessment targeting Azure SQL Managed Instance.
Documentation:
Overview of Data Migration Assistant
Numerous "deprecated" features, such as returning result sets from triggers, using deprecated hash algorithms in the HASHBYTES function, and so on, are not appearing at all in the assessment results. Clearly, the documentation is incorrect.
Am I missing something here?

What is a SSMS analogue for Oracle?

What is (if there is) the analogue of SQL Server Management Studio for Oracle databases?
Question seems easy but Google didn't know a thing.
I've never worked with Oracle database, now I will have my first encounter soon so I'd like to be a little prepared.
It depends. There are a number of applications that could be used depending on what specifically you are trying to do.
If you are trying to administer the database, you would probably want to use Enterprise Manager. This is a web-based application that lets you monitor and administer the database. It can either be configured to run just on a particular database server (Enterprise Manager Database Control) or it can be configured to allow you to access all the databases and a variety of non-database products running in the organization (Enterprise Manager Grid Control). Grid Control is, obviously, a much more involved install. The Database Control should be installed when you install the database (though some DBAs will turn it off because they don't want to run a HTTP server on their database server).
If you are trying to write and debug PL/SQL code (packages, procedures, functions, triggers, etc.) or to just run some ad-hoc SQL statements, Oracle provides a free tool SQL Developer that can be used. There are a variety of other PL/SQL IDEs out there as well-- Toad from Quest and PL/SQL Developer from AllAroundAutomations are two of the more common ones.
Oracle also has a basic command-line SQL tool SQL*Plus that will exist pretty much wherever you are (in much the same way that vi will be available on just about any Unix machine you log in to). There are lots of DBAs (and a decent number of developers) that prefer to use SQL*Plus rather than using the various GUIs. At a minimum, in most large organizations, DBAs will use SQL*Plus to execute scripts built by the developers as part of the code promotion process so you'll want to have a basic familiarity with SQL*Plus.
You can use Oracle SQL Developer which is free from oracle.
Toad is also available.

Are there any good tools for SQL Server database design static analysis?

I'm interested in the existence of any tools which can perform static analysis against a SQL Server database. In essence, I'm looking for the DB equivalent of FxCop or NDepend; something which can inspect the data layer and come back with recommendations around metrics such as design, naming and any other measurable attributes relating to quality.
Has anyone used a tool in the past that can provide some design feedback? Thanks.
If you use SQL 2008, or have an instance of SQL 2008 anywhere, you can use policy based management. This will do what you want. Check Here This will work for naming and other standards, but might not work on data metrics.
You can alway use the Microsoft Best Practices analyzer for SQL
DataCleaner http://datacleaner.eobjects.org/
SQL Enlight is a dedicated static analysis tool for SQL Server, working in SSMS as well as part of Continuous Integration. There is a review on Simple Talk by Grant Fritchey. There are numerous built-in tests as well as a capability (albeit complicated looked) to author one's own checks.
SQL Cop is another option. It's not as sophisticated as SQL Enlight, and can't be automated as part of a build process, but is free.

Recommendations for supporting both Oracle and SQL Server in the same ASP.NET app with NHibernate

Our client wants to support both SQL Server and Oracle in the next project. Our experience comes from .NET/SQL Server platform. We will hire an Oracle developer, but our concern is with the DataAccess code. Will NHibernate make the DB Engine transparent for us? I don't think so, but i would like to hear from developers who have faced similar situations.
I know this question is a little vague, because i don't have Oracle experience, so i don't know what issues we will find.
You can easily use NHibernate to make your application database-agnostic by following some basic practices:
Design your object model first.
Do not use any database-specific code. You need somebody with good C# experience, not an Oracle developer. Do not rely on stuff like triggers, stored procedures, etc.
Let NHibernate generate the DB schemas at least initially (you can tweak things like indexes later) It will choose the best available datatypes for each DB.
Use a DB-agnostic POID generator (hilo or guid) instead of sequences or identity.
Try to avoid using SQL. HQL and Linq work fine in 99% of the cases.
Avoid NH features that are not supported by all of your target DB (for example, Future, MultiCriteria, etc)
NHibernate has a great community. You can always ask your questions in http://groups.google.com/group/nhusers besides posting here.
There are three things to consider - the ISession object, the SQL queries that are generated and your plain-old-clr-objects that are mapped to tables.
NHiberante will generate the required SQL queries based upon the chosen database dialect. If you configure NHibernate to use the SQL Server dialect it will generate SQL server correct SQL statements. This can easily be configured dynamically at runtime based on configuration.
You also need to configure your session to connect to the right type of database. Again, various configuration methods can support dynamic ISession creation at runtime.
Your actual data objects which are mapped to tables should not need to change based on database choice. One of NHibernates strengths is flexibility it provides in supporting multiple databases via a (fairly) simply configuration change and some up-front architectural thought.
See http://codebetter.com/blogs/karlseguin/archive/2009/03/30/using-nhibernate-with-multiple-databases.aspx for some examples of how you might abstract the underlying database away from the creation and usage of NHibernate.

Resources