how to use one core project for a SQL Server 2014 and Azure SQL Database - sql

we want to deploy our Software on different editions of SQL Server. So we made a CoreDB Project, and for every edition (Express, Standard, Enterprise) seperate projects. Each references the CoreDB to reduce the amount of objects to define.
Now we want to deploy to Azure DB, but we can not reference the CoreDB from an AzureDB Project.
Any Ideas?
Thank you!

Assuming that you are referring to creating CoreDB and AzureDB as Database projects in SSDT -
Unfortunately SSDT will not allow you to create a Database Reference to another database with a different version. To relate to your earlier example, the following scenario will not be allowed in SSDT:
CoreDB's target platform is SQL Server 2014
AzureDB's target platform is Microsoft Azure SQL Database V12
Check a similar question posted here: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/af6005a6-5c4d-4c1c-bd8b-209d320ceef7/error-setting-up-db-reference-from-dacpac-versions-dont-match?forum=ssdt
If you've found a way of "reusing" the CoreDB code for different versions since you last posted this, please let me know.
Personally (and based on past experience), I'd use source control to create different branches reflecting the different versions. This allows independent release and code management. It does require more deployment management and synching up, to ensure that the relevant objects will get the same updates.
Julie

Related

Make versions of MS SQL Server Stored procedures and functions

I have problem that is all my team members are altering the Sps and functions and
some conflicts occurred through the development
is there anyway or tool to store and get all version of them ?
the problem is before releasing the new version, i don't want a tool to compare difference between two databases like what Red gate SQL_Compare
thanks in advance
You may make use of the features in Visual Studio and TFS(or any other source control mechanisms). All that you need to do is to
Create a SQLServer DB Project in Visual studio and configure it to
your desired database.
Bind the project to a source control (TFS,
SVN etc.,)
Every time you have a change in DB, you can just compare the changes using .scmp file and click update.
You may refer this post for more information:
http://candordeveloper.com/2013/01/08/creating-a-sql-server-database-project-in-visual-studio-2012/

Database reverse engineer installation

I have an existing database (SQL Server 2008 R2), and my goal is to have a project that can install the same database as I already have.
i.e the project will read the schema and the data, and will be able to duplicate the existing data and schema.
This tool needs to save the database information to disk so I will able to install the database on different machines.
Can I do it with Visual studio 2010 database projects?
Is it a simple task?
(The reason I am asking is that I already have such a project that installs my database, but this tool is very old(~2000).
That old project is one big mess, it has C#, java, sql, batch files and some 3rd party tools and has many more capabilities than I need for my current product..)
Thanks.
Use SQL Server Management Objects (SMO) to create a snapshot of your source db and then restore it to the target server.
More on SMO here: http://msdn.microsoft.com/en-us/library/ms162169.aspx .
A nice tutorial here: http://www.codeproject.com/KB/database/SMO_Tutorial_1.aspx
The easiest way is to backup using SQL server management studio. Then move the backup file to the second server and there restore it with SQL server management studio. If you need SQL code to do it (instead of GUI way), just drop a comment...
This codeplex project has a basic library that does that if you like to roll your own and has two sample projects for migration/comparison tasks.
http://dbschemareader.codeplex.com/
Also the commercial option is to use Sql Redgate's tools. They are expensive but worth every penny if this is a mission critical database. On the otherhand, if you are just using a db as an alternative to a file, say in a embedded scenario, it might be hard to justify such an expensive tool.
Have you tried DBSourceTools ? http://dbsourcetools.codeplex.com
It is an open-source database versioning tool that will script out all database objects and data to disk, and then re-create the database on another machine.
It has all of the features that you are looking for.

sql server folder questions

I thought I read somewhere that in 'denali' we would be able to place tables within management studio into logical folders. For example I have 20 tables releating to clouds, i could create a clouds folder and group the tables logical, thus i can hide/expand that folder to see the tables. Is this already done in 2008 r2? *Or did i read correctly and it will happen in denali?*
SQL Server Code-Named Denali (or likely to be officially named 2011), has released its CTP 1. Along with it is SQL Server Management Studio.
Within, as it stands today, you cannot organize tables into 'folders' for visual organization.
There are many 3rd party solutions which could implement such a feature but MS has not implemented in their tools yet.
However, here is a potential solution: Management studio does allow you to define a filter on the tables list. If you are working on one area you can right click on the table leaf and select filter. Maybe this will help to restrict your view to just the tables you are interested in working with at a given time.

SQL Azure schema upgrade strategy

i'm currently working on a asp.mvc application with entity framework as db backend which will be running on ms azure platform.
on my development machine i'm running a sqlexpress instance which hosts my development database (like i said may app connects via entity framework to it).
deploying the database schema from my local sqlexpress to sql azure is pretty easy via the entity framework database generation wizard (for whatever reasons the wizard always wants to create some clustered indexes which i correct manually in the generated sql file).
but i can't figure out a way to keep my data! the auto generated sql script always dumps all my tables and creates new ones...thats ok for initial setup, but not to upgrade a existing database.
there must be a nice way to perform a schema update without dataloss...please help! i have already tried sql management studio (r2) and SQLAzureMW (available on codeplex)...but they don't do the job :(
please don't tell me i have to code my own tool to do that!
looking for your help
thx
Edit: here's how i do it now
I use the SQL scripts created by the EF migration wizard for my local SQL Express and modify them myself to be compatible with SQL Azure. Is less work that one might think and works perfect :)
Have you tried to use BCP to export and then import your data? I believe you should be able to use BCP to export data from your SQL Express instance into a file, and then import data from the file into SQL Azure. The SQL Azure team has a blog posting that describes using BCP with SQL Azure - Link.
Additionally, in the future, the upcoming release of SQL Azure Data Sync CTP2 might be able to help you out.
Out of curiosity, what problems where you having with SQLAzureMW?
RedGate is famous for SQL server synchronization and data synchronization for deployment purposes.
They have a v9 beta out of their DataCompare and SchemaCompare products that are compatible with SQL Azure. I've been using both successfully and like them alot.
They are pricey when purchased, if you are a small business.
http://www.red-gate.com/Azure
This sounds vary similar to this question, the only answer to which is "wait for the next version of entity framework". I'll admit that I don't use EF, but I make my changes to tables the old school way with SQL Server Management Studio and scripts. ALTER TABLE FTW.
EDIT: If you don't have access to SQL Server Management studio, the new version of the SQL Azure portal includes a Silverlight based application that allows you to run queries and scripts

Automatic incremental SQL Script generation for incremental, nightly builds when using Team Build in TFS 2008 and Visual Studio 2008?

hope that everybody here is OK.
We are using VS 2008 as development tool, TFS 2008 as version control as well as build automation. Some of our developer use dbpro for databases changes and some use SQL Server management studio.
I am trying to automate build for Web Application built using C# and VB.Net.
Our scenario is such that we have a central database to which our web application connects.
Whenever we supply our clients with a new functionality or a bug fix, we supply them incremental builds.
The SQL script is checked into source control for every incremental build when they have made and tested there changes on our central DB Server.
I want to generate Differential script that can be run at the client as an incremental update script. Now to come about it is a problem. Sometimes our developers tend to forget the database change-sets and the script in the source control is missing an SP or a two.
Also, sometimes we need to insert default data into some of the tables that have strict stringent values and not test values. Like a table that contains Services provided by the panel, we add a new service name, signature, credentials and service address, etc etc in the ServiceTable. Besides this many other tables may have test data that may not be needed.
If we use DataCompare, it will generate changeset for required data (important for client to enable certain services) and our test data that was added to the database as a result of our testing of the functionality or bug fix.
Currently i am using SQLSchemaCompareTask (from Visual Studio 2008 Team Database Professional Power Tools API) in the TFSBuild.proj file of the build definition for TFS 2008.
Using SQLSchemaCompareTask, the script generated contains database names like [dbo]. etc which are not desired as the script fails when run against SQL Server 2000 databses (Some of our client still use SQL Server 2000) databases as teh backend of the application.
Also default data can't be generated by this process.
To overcome this problem, i have to come up with a solution that can compare databases and generate script automatically that does not have to be manually reviewed again before being sent to the client.
Please suggest effective methodology of such SQL script generation and suggest whether two different databases may be used or something ? Is there any toolkit or api that can enable build automation for SQL Server databases?
Thank you all.
Regards
Steve
Try to use SQL Examiner Suite for this:
http://www.sqlaccessories.com/SQL_Examiner_Suite/
The tool compares both schema and data and produces synchronization scrips (or differentials scripts). You can automate script creation with supplied command-line tool.
Rather than collating many individual change set scripts (and therefore occasionally missing objects out), why not use schema compare and data compare to create a single script from your database project using a database equivalent to your client's on the target? This should create a script tailored to their requirements.
In data compare you can exclude test data records that you don't want pushed to your client by unchecking them in the lower grid.