Database Migration Assistant not detecting deprecated features - sql-server

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?

Related

Convert SQL Server queries to Postgres on the fly

I have a scenario where I get queries on a webservice that need to be executed on a database.
The source for these queries is from a physical device so I cant really change the input to my queries.
I get the queries from the device in MSSQL. Earlier the backend was in SQL Server, so things were pretty straight forward. Queries would come in and get executed as is on the DB.
Now we have migrated to Postgres and we don't have to the option to modify the input data (SQL queries).
What I want to know is. Is there any library that will do this SQL Server/T-SQL translation for me so I can run the SQL Server queries through this and execute the resulting Postgres query on the database. I searched a lot but couldn't find much that would do this. (There are libraries that convert schema from one to another but what I need is to be able to translate SQL Server queries to Postgres on the fly)
I understand there are quite a bit of nuances that will be different between SQL and postgres so a translator will be needed in between. I am open to libraries in any language(that preferably runs on linux : ) ) or if you have any other suggestions on how to go about this would also be welcome.
Thanks!
If I were in your position I would have a look on upgrading your SQL Sever to 2019 ASAP (as of today, you can find on Twitter that the officially supported production ready version is available on request). Then have a look on the Polybase feature they (re)introduced in this version. In short words it allows you to connect your MSSQL instance to other data source (like Postgres) and query the data in as they would be "normal" SQL Server DB (via T-SQL) then in the background your queries will be transformed into the native pgsql and consumed from your real source.
There is not much resources on this product (as 2019 version) yet, but it seems to be one of the most powerful features coming with this release.
This is what BOL is saying about it (unfortunately, it mostly covers the old 2016 version).
There is an excellent, yet very short presentation by Bob Ward (
Principal Architect # Microsoft) he did during SQL Bits 2019 on this topic.
The only thing I can think of that might be worth trying is SQL::Translator. It's a set of Perl modules that have been around for ages but seem to be still maintained. Whether it does what you want will depend on how detailed those queries are.
The no-brainer solution is to keep a SQL Server Express in place and introduce Triggers that call out to the Postgres database.
If this is too heavy, you can look at creating a Tabular Data Stream (TDS is SQL Server network transport) gateway with limited functionality and map each possible incoming query with any parameters to a static Postgres query. This limits any testing to a finite, small, number of cases.
This way, there is no SQL Server, and you have more control than with the trigger option.
If your terminals have a limited dialect demand then this may be practical. Attempting a general translation is very likely to be worth more than the devices cost to replace (unless you have zillions already deployed).
There is an open implementation FreeTDS that you could use if you are happy with C or Java.

How to audit SQL Server schema updates

Is there a way to see who updated which database object and when? I would like to be able to see which developer made a change to some table or stored procedure (or any other object) historically.
I know that we can implement DDL triggers and start capturing this information from this point on but is there a way to see historical data. Database is on SQL Server 2008 R2 Standard edition.
There is no standard way to see this data but it might be possible using 3rd party tools. If your database was in full recovery mode then you can try reading transaction log using 3rd party reader such as ApexSQL Log or Quest Toad. ApexSQL Log specializes in log reading and has more options for this while Toad is similar to SSMS and has many other options for general database management.
Native tools indeed do not provide such option, as for 3rd party tools I suggest you to take a look at SQL Server Change Reporter
from NetWrix (disclosure: I work for them). It has both freeware version as well as free trial. The product shows what changes were made to objects, who made the changes and when. This should be a solution you are looking for.

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

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.

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