Determine Target SQL Platform from a dacpac - dacpac

Is it possible to determine the Target Platform that was used when
creating a dacpac. I've looked at all of the parameters for SqlPackage.exe
and none of them seem to give this information. Ideally I'd like to be able
to determine this from the command line but if there was some way of determining
it from Visual Studio as well, that would be fine.

The simplest way to figure out the target platform of a given dacpac is to unzip it and look at the model.xml file inside. There will be a "DatabaseSchemaProvider" specified in the XML, which will be one of these:
Sql90DatabaseSchemaProvider - SQL Server 2005
Sql100DatabaseSchemaProvider - SQL Server 2008
Sql110DatabaseSchemaProvider - SQL Server 2012
Sql120DatabaseSchemaProvider - SQL Server 2014
Sql130DatabaseSchemaProvider - SQL Server 2016
Sql140DatabaseSchemaProvider - SQL Server vNext
SqlAzureDatabaseSchemaProvider - Azure SQL Database
SqlAzureV12DatabaseSchemaProvider - Azure SQL Database V12

Related

How to Migrate TFS SQL Server 2014 DB to 2012

We are using TFS 2013 and SQL Server 2014. A client of ours is requesting the TFS project and also uses TFS 2013 but with SQL Server 2012. How can we go about migrating? Will a simple backup and restore work when downgrading from 2014 to 2012?
You CANNOT do this - you cannot attach/detach or backup/restore a database from a newer version (like 2014) of SQL Server down to an older version (SQL Server 2012) - the internal file structures are just too different to support backwards compatibility.
And no - setting the compatibility level to 110 (for SQL Server 2012) in SQL Server 2014 also doesn't help ; it will prevent your T-SQL code from using new SQL Server 2014 T-SQL features, but it does not change the internals of the database file in any way, shape or form.
You can either get around this problem by:
using the same version of SQL Server on all your machines - then you can easily backup/restore databases between instances
otherwise you can create the database scripts for both structure (tables, view, stored procedures etc.) and for contents (the actual data contained in the tables) either in SQL Server Management Studio (Tasks > Generate Scripts) or using a third-party tool
or you can use a third-party tool like Red-Gate's SQL Compare and SQL Data Compare to do "diffing" between your source and target, generate update scripts from those differences, and then execute those scripts on the target platform; this works across different SQL Server versions.
Update by #MrHinsh:
WARNING: While these options may work for your own database projects it will NOT work for TFS. Changing the Database schema, moving data, or editing the tables will BREAK TFS and will invalidate your support agreement with MSFT
Backup / restore isn't a viable approach here - no version of SQL Server knows what was changed in the database files' formats for the next version.
So copy database schema and data from 2014 to 2012 and pray it will work - chances are, it wouldn't. There should be an Import / Export wizard in SSMS, at least it was there before.

Upgrade Pubs and Northwind Databases Failed in Visual Studio 2013

I'm using VS Ultimate 2013 and SQL Server 2014 Standard. I try to upgrade Pubs and Northwind databases but the operation fails with the following snapshot:
Besides that, I followed paths introduced in some corners of the net but I got no interesting results. What should I do?
Thanks
Update[Problem solved by #marc_s]:
The SQL Server 2012 Northwind database version bypassed the obstacles I had. Here's the link: http://businessimpactinc.com/install-northwind-database/
The error says
User instance flag is not supported on this version of SQL Server
You seem to be trying to use
User Instance=true
in your connection string, but that is supported exclusively in SQL Server Express - no other edition (and therefore, it's not supported on SQL Server Standard).
You will need to attach the .mdf files (or run the creational SQL scripts for those two databases) on your server instance¨and then connect to those database on the server

Cannot restore a database with a .bak file due to another SQL server version

I have installed SQL server 2008 R2 and i try to restore a database a colleague sent me in a .bak file.
Unfortunately, i cannot restore the database since the database was saved on a server from version 10.50.1600 and my SQL server version seems to be 10.00.1600.
I tried to upgrade my SQL server with SP1 and SP2 packs but it didn't change anything.
Otherwise, i noticed by clicking on the server property that the line "product" displays Microsoft SQL server Express edition even though i have installed SQL server 2008 R2. That's at least what is displayed when i fire it...
Can anyone help me ?
Thanks in advance
You CANNOT do this - you cannot attach/detach or backup/restore a database from a newer version (SQL Server 2008 R2 - 10.50.1600) of SQL Server down to an older version (2008 - v10.00.1600) - the internal file structures are just too different to support backwards compatibility.
You can either get around this problem by
using the same version of SQL Server on all your machines - then you can easily backup/restore databases between instances
otherwise you can create the database scripts for both structure (tables, view, stored procedures etc.) and for contents (the actual data contained in the tables) either in SQL Server Management Studio (Tasks > Generate Scripts) or using a third-party tool
or you can use a third-party tool like Red-Gate's SQL Compare and SQL Data Compare to do "diffing" between your source and target, generate update scripts from those differences, and then execute those scripts on the target platform; this works across different SQL Server versions.
Understand, what the version numbers mean. You need to be on R2 which is not just a patch or service-pack.

SQL Server version 612 , 655?

I have SQL Server 2008 and VS2008 installed on my computer and I am trying to run a web application I've created on a computer which has SQL Server 2008 and VS2008 and VS2010 beta 2 with its SQL Server Express.
I am getting an error with the database version that is
"...aspnetdb.mdf" cannot be opened because it is version 655. This server supports version 612 and earlier...."
Configuring the database in Visual Studio ->Tools -> Options -> Design-Time Validation Database is not working since I don't have the SQL Server version comes with VS 2010.
EDITED : I also edited aspnetdb and inserted a few more tables so I need the same aspnetdb
Is there any solution to convert this db ?
Also, after fixing this, I am looking forward to upload it on my hosting which has SQL Server 2005 DB and configure it in PLESK.
The SQL Server databases have a version specific format. Each SQL Server runtime version (SQL 2008 SP1, SQL 2008 RTM, SQL 2005 SP2, SQL 2005 SP1, SQL 2005 RTM etc) knows how to upgrade to its own verison. Unfortunately, once upgraded the database cannot be downgraded. So if your MDF was upgraded to version 655, it cannot be downgraded to any prior version. If you know you're going to deploy on SQL Server 2005, you must develop on SQL Server 2005 too. Not only that, but the actual build number of your development has to match the build number of the deployment (or at least be lower than that): the SP level and CU level must match.
You can a attach the 2008 version MDF you created to a SQL Server 2008, script out the database content, then import the script into a SQL Server 2005 database of the proper version.
I had this problem and when I changed my_computer_name\SQLEXPRESS with . to connect to server and it works and I could attach MDF file
may be you have both services run. (Mssql2008 and mssqlexpress) Maybe you have runing the mssqlespress running, that's the error that you have. Try to stop the mssqlserver express service and run mssql2008 services, and attach again your databases. I try this and works for me

Configure VS2008 to create SQL Server databases instead of SQL Server Express?

Probably asked and answered before, but difficult to search for.
In VS2008 when you right-click App_Data folder and create new database, it attempts to create a SQL Server Express database. Well I have SQL Server 2005 Standard installed and have thus uninstalled Express. How do I get VS2008 configured to know I want SQL Server databases (NOT Express) created?
SQL Server Express databases are SQL Server databases and vice-versa. While is true that the SQL Server 2008 database files format is different from SQL Server 2005 one, whthin the same version (2005, 2005 SP1, 2005 SP2, 2008 , 2008 SP1 etc etc) all SKUs (Express, Standard, Exnterprise etc) have all the same datbase format.
Yout Visual Studio tools are guiding you down the wrong path. You should not use the Solution Explorer to add a database to the App_Data folder. Instead you should use the Server Explorer tool (menu View/Server xplorer or press Ctrl+W,L) and connect to your SQL Server 2005 instance. Then use the Server Explorer tool to explore the database. To connect to the database from your solution, add a connection string to the web.config file.
While you can manage the database objects from the Server Explorer, thar is a horrible way to do it and will cause only pain on the long run. You should instead create deployment scripts with DDL statements and run those scripts when the solution is deployed. This way your database metadata is part of your source control and you can keep track of application database versions, see Version Control and your Database.

Resources