Does fluentmigrator work with SQL Server 2012? - sql-server-2012

Does the current iteration of fluentmigrator work with SQL Server 2012? Its not listed under the supported databases.

There is no official support for Sql Server 2012 yet. But it should work if you specify SqlServer2008 as the database type. The differences between Sql Server 2005, 2008 and 2012 are not so significant when using FluentMigrator (Sql Server 2000 is a different story). Some features like the new sequence object have no support so in the meantime will have to be run using Execute.Sql.
UPDATE: I tested FluentMigrator against Sql Server 2012 Express with database type specified as SqlServer2008 and it worked fine.
UPDATE: FluentMigrator now officially supports Sql Server 2012 and Sequences.

Related

Forcing SQL-scripts to be compatible with a specific Microsoft SQL Server version

During our development cycle we create migration-scripts that will be executed on multiple Microsoft SQL Server instances (on different servers).
Since these servers are being maintained by multiple third parties, we can't guarantee that all of them are using the latest Microsoft SQL Server version. For example, some of them are still stuck on 2008 R2.
Unfortunatly, this means that our SQL scripts must at least be compatible with 2008 R2 (and higher).
We would like to add an extra step to our build process (currently driven by MSbuild), which should check if all scripts are compatible with all versions of SQL Server that we should support (2008 R2 and higher). Both in terms of their syntax, but also in terms of built in functions (as an example, the CONCAT-function was only added in 2012).
However, we want to avoid having to install each supported SQL Server version and instead use only SQL Server 2017.
Note:
I've had a look at compatibility modes in SQL Server, but when I set the compatibility level to 100, I seem to still be able to use SQL Server 2012 features like the CONCAT-function. Which doesn't surprise me, as I expect this to be intended for backward compatibility, rather than blocking features.
These similar questions didn't really help either: Using SQL Server Express 2008 with SQL Server 2005 database -how to check for compatibility, How to check sql script compatibility agains SQL 2008
Are there any other options?

How to make SQL server 2000 compatible with SQL server 2008

I need to dump a software to a clients server. The problem is that my software is using SQL server 2008 and the client is using SQL Server 2000. So could anyone please suggest how I can make the clients SQL server 2000 compatible with my queries of SQL server 2008?
Thanks for the suggestion
But my concern is that software is already developed with SQL server 2008, then is there any way to use it with SQL server 2000?
You should have developed your software against SQL 2000, or demanded your client upgrade to at least 2005. Did
you ask the client which version you would deploy to before starting development? That is part of standard requirements gathering.
SQL 2008 queries may or may not be compatible with SQL 2000 due to
many new features in 2005 and 2008. There is no shortcut.
At best, make sure to use SQL 2000 documentation from MSDN when writing queries. Use the lowest common denominator.
If you are supporting a product that must deploy to multiple SQL Server versions, you may consider using an ORM that supports SQL 2000. Checkout the Nuget gallery of ORMs: http://staging.nuget.org/packages?q=Tags%3A%22ORM%22 - I believe something simple like Dapper supports 2000.
At minimum you should set your SQL 2008 compatibility level down to 2000 during development.
http://msdn.microsoft.com/en-us/library/bb510680.aspx
ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = 80
I recommend you setup a virtual machine, install the older OS that your client uses as well as SQL Server 2000. Otherwise there are unforeseeable differences.

How can I restore a database backup file (.bak) from SQL Server 2012 into SQL Server 2008 Express?

A database that was originally from SQL Server 2008, was restored into SQL Server 2012. A backup from SQL Server 2012 was made and I am trying to restore it on my local SQL Server 2008 Express. However I get an error 'Specified cast is not valid' (SQLManagerUI).
I have generated an SQL Script from 2012 and set it so that it will generate with compatibility to SQL Server 2008. However it is a large sql file, around 700mb.
I recall before that I had tried to run a script of that size before on my local SQLExpress and also got an error.
Is there a way I can get a "large" database from SQL Server 2012 into SQL Server 2008 Express?
Thanks to Marc and Aaron for providing the answers.
The quick answer is no, it's not possible to restore a backup file from a higher version to a lower version of SQL Server.
A work around would be to generate the scripts to create the database.
You can target the script generation to a lower version.
Please see comments above for more information.
Links:
Why an SQL Server Database from a higher version cannot be restored onto a lower version of SQL Server?
Create Database in SQL Server 2012, Script and Use in 2008?
Couple things to add that might be helpful to folks
When scripting large databases using scripting wizard in SSMS it’s really important to check the execution order and be willing to re arrange it manually. Older versions of SSMS had this problem because they (probably) relied on sp_depends that has a bug.
What I’ve found really useful in such cases are tools like ApexSQL Diff that you can use to read database backups and generate scripts that are in correct execution order.
SQL Server database backup restore on lower version
One thing that none of the methods will catch is the thing Aaron mentioned about using functions specific to higher version.
A better option than using the SSMS scripting wizard is to use a similar tool available on Codeplex called SQL Database Migration Wizard - http://sqlazuremw.codeplex.com/releases/view/32334. You want the latest version v4.x to work with SQL Server 2012.
The tool is originally intended to be used for migrating databases between SQL Server and Azure. However the tool works just as well as between SQL Server and SQL Server. The trick is to set SQL Server rather than Azure as the target in the advanced options.
The reason this is a better option than the SSMS scripting wizard is that it uses BCP for the data transfer rather than TSQL and so is much more efficient.

Move database from sql server 2008 to 2005

I have a database currently in SQL Server 2008 to be moved to SQL Server 2005. I would like to backup the 2008 db to a bak file and import it to 2005, but couldn't find any options in SSMS 2008 while taking backup. Has anyone had a similar need in the past? How did you manage this through?
To restore the backup to an older version of SQL Server you can use third party tools, ApexSQL Diff and ApexSQL Data Diff.
You can read detailed explanation of the process in this article: Restoring SQL Server database backup to an older version of SQL Server
Hope this helps
Disclaimer: I work for ApexSQL as a Support Engineer
You could try the Publish Database Wizard.
From the link:
The source database must be on an instance of SQL Server 2005, SQL Server 2005 Express Edition, or SQL Server 2008. The target database must be on an instance of SQL Server 2000, SQL Server 2005, SQL Server 2005 Express Edition, or SQL Server 2008.
I don't think you can restore 2008 backup on 2005 server. Try 3rd party schema/data migration tool, like SQL Examiner Suite or RedGate's SQL Compare
You cannot do this. You never could restore a more recent SQL Server database to an older version.
Your only option is to script out the data you need to insert, or use a data comparison tool like Red-Gate SQL Data Compare to compare the two databases (and update your older one from the newer). SQL Data Compare will also work comparing a backup (any version) to a live database on a server.
It's easier than that, since (assuming your db isn't using any 2008-only features) they use the same format (*.mdf). Simply detach your database from your 2008 server, copy the mdf file to the 2005 server, and attach the copy to the 2005 server. Look for the Attach/Detach option when you right click on a database in sql server management studio.

Methods to migrate SQL Database (mdf) to SQL Compact Edition (sdf)

I have 4 SQL Server 2005 db's that I want to move to SQL CE. I know I cannot keep the SProcs,Views, and Functions(Differences Between SQL Server Compact and SQL Server) but I would like to keep everything else.
I have tried this app, SQL Server to SQL Server Compact Edition Database Copy but it errors out on me. I have the source and am looking into it but I thought I'd check and make sure I wasn't over complicating the solution to my ACTUAL goal.
Is there a simple, can be one shot, way of converting standard SQL .mdf to SQL CE .sdf?
Right now my best idea is to set up Replication to the SQL CE from the SQL 2005 Standard.
http://erikej.blogspot.com/2010/02/how-to-use-exportsqlce-to-migrate-from.html
1.Use SQL Server to SQL Server Compact Edition Database Copy with sqlcompact 3.1 or 3.0 not sql compact 3.5
You can use a virtual machine like sun virtual box, install sql compact 3 or 3.1 on it, and convert your database inside it
2.You can convert to sql compact manually
Use the SDFViewer utility:
go Tools Menu > From SQL Server
Enough said....
What if you scripted the objects from 2005 and ran the script in CE? That'd give you the structure of the DB, then you could select/insert?
I haven't tried this, but what about SQL's DB export/import tools in management studio?