Database project deployment - visual-studio

I have database project in visual studio 2010. It has tables views stored procedures etc. I have created a full text index on view and in stored procedure I am using like this:
create proc myproc
as
select * from my view
where contains(tblperson.fname,'Steve')
end
When I deploy, I get error that I can't use contains as view is not full text indexed. I want to know if there is a sequence in which database project is deployed ? means first stored proc is deployed or views are deployed. Can I change this sequence.
Please suggest.

The Visual Studio Database projects are great! I have just migrated from Db_Deploy integrated with SVN to TFS Visual Studio Database projects. The database projects work by creating a self contained db schema file and when you use the VsDbCmd command for deployment, it will do a schema comparison between the project schema and the database schema to generate the delta script for you. The order in which the comparison takes place is Tables, Procs then Views, ...
I would suggest that you apply this script direct on to the database and then use the schema comparison from database to project to soak in the changes. This way the visual studio database project will create the script for you. Read more about the db comparison and walkthrough on msdn http://msdn.microsoft.com/en-us/library/aa833435.aspx.
PS - How are you managing deployments of your db project? I have automated the entire deployment suit, interested to know how others are doing it.
HTH.
Cheers, Tarun

Related

DataBase project in Visual Studio

I have two database projects in Visual Studio which is purpose to deploy databases separately. First database project deploy DBFirst and second database project deploy DBSecond. DBFirst database is created successfully but I am struggling with second.
DBSecond contains stored procedures and views. Some of them referenced to DBFirst and DB project failed during the build process. Example I have following view in DBSecond:
CREATE VIEW [dbo].[DBFirst_CLM_Details]
AS
SELECT *
FROM [DBFirst].[dbo].[CLM_Details]
GO
That project failed during the build because it cannot resolve reference DBFirst. If I change "Build Action" property from Build to None project will build but it will skip that file.
How can I deploy that view and similar objects which have references to another database? I am using VS 2013 and target platform is MS Azure SQL Database
Thanks
Cross-database references are not supported by Azure SQL Database. If you need it you should go and vote for it to help prioritise its delivery. If you need the capability today you will need to invest time in querying and combining the data elsewhere in your application outside of Azure SQL Database.

Reload database objects in a VS database project?

if I create a SQL Server 2008 Database Project in Visual Studio 2010, then I am able to right click the project and select Import Database Objects and Settings.... I can do that exactly one time (even if I get an error while importing). If I did it one time, the option is grayed-out.
But after I have imported my objects, I couldn't find a way to reload or refresh the objects. A good example would be, that I have a database project of a whole database and someone adds something to the database directly. Now I want to have new table (function, procedure, etc.) in my project, too.
There has to be a better way than copy&paste to add new existing database objects to my database project?
I found this question:
Script all SQL database objects into VS Database project
But I neither have a Schema Compare option, nor can I drag&drop files from the server explorer.
In Visual Studio you should see a menu choice that says Data. If you click on that, you should be able to run a Schema Compare. If you're not seeing that, then there's something wrong with your VS install or the project or maybe both.

How can I manage SQL Server jobs using a Database project

Does Visual Studio 2010 support managing SQL Server jobs in the Database Project?
I am working with a database project in Visual Studio 2010. I would like to manage my database scheduler job in my database project. It seems that I could not create any server object in the database project.
What we do at my company is:
Script out your jobs to be re-runnable (either drop/create or skip if exists)
Place the scripts in your Post-Deployment folder (and include the reference in your Script.PostDeployment.sql file as necessary)
No, you won't be able to do that. If you want to use Visual Studio to manage database projects you can use the database and server projects (what used to be called Data Dude).
You might also want to take a look at Red Gate SQL Connect. It works with databases and source control through Visual Studio.

Database in version control using Visual Studio 2010 Professional

I've added a SQL Server 2008 database project to my Visual Studio 2010 Professional Edition solution in the hope that it might allow me to include my database in version control.
I can commit the schema files for each database object into version control, however these schema files all script objects as create rather than alter, so are not good for colleges getting my changes and updating their databases.
Is this a good way to get my database into source control?
And what would the workflow be for actually using it to update databases to a given revision without losing all the data associated with dropping and re-creating all the tables?
Update: on Premium and Ultimate versions, there is a schema compare tool which makes this easy. This does not exist on Professional. Is there any straightforward manual workaround?
I'm not sure if you can do this in VS 2010 Professional, but in VS 2010 Premium, you can do a schema comparison (Data -> Schema Compare -> New Schema Comparison) between your project and database, and update changes in either direction.
When going from project to database, VS generates a script that copies existing data into a temporary table before dropping the existing one.
The database project has a deploy step (which is present in my Professional copy of VS2010) that will generate a sql script with your sql objects in it.
The key thing here is if you r-click the project, properties, goto deploy and change target database settings to a specific database, when you deploy it will generate a change script for that specific database so it matches the objects in the project (and in theory keep existing data etc).
You can get it to either generate a sql script, or directly update the database. Generating a script is probably a better idea :)

Visual Studio 2008 Database project Deployment Baseline

I have a question about creating a deployment script using a database project in Visual studio 2008.
In a more traditional project we would create a deployment script that would create the DB and the initial objects for the first deployment. This would become the baseline.
Any additional objects would be scripted as ALTER statements. Each statement would check for the existence of the object, giving a re runnable database deployment script.
I want to be able to do the same thing with the database project, but it currently analyses the database and creates a script to take it from its current state to where the project specifies it should be. This is fine for local deployment, but I cannot use this to deploy to production, as they require a re runnable script that will not loose any data in the live system.
My first idea was to have a copy of the database that matches live, and then point the project to it to generate the statements for the deployment, but it does not seem very maintainable.
Does anyone have any idea about how achieve this?
Thanks
This is done by the Schema Compare option of the Database Edition of Visual Studio.
I Think you could find useful this link:
How to: Compare Database Schemas

Resources