How can I manage SQL Server jobs using a Database project - visual-studio-2010

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.

Related

How to save a SQL Server Maintenance Plan within a Visual Studio Database Project

Having created a SQL Server maintenance plan in a SQL Server 2008 R2 instance, how can I import the definitions into a Visual Studio 2013 SSDT database project?
I don't mind using pre- and post-deployment scripts if that helps but I want it to be in a database project and to be able to build the project in VS and then to be able to deploy either a new instance of the plan, or to be able to synchronize an existing plan instance with the definitions in the database project. Also, drop and re-create is entirely acceptable.
Does anyone else already know how to do that ?
First of all maintenance plans are not supported by SSDT.
You can export it manually as an xml template file and then try to write some sql/batch post deploy scripts to deploy it.
You can find general instruction here (read comments also): https://robertbigec.wordpress.com/2013/10/03/automating-deployment-of-sql-server-maintenance-plans/
One note: The exported xml template contains some specific values such as server name or path to backup/log file locations. You might want to write custom script to get these values from target machine and replace it in the xml file.

Visual Studio Project that execute an SQL script

I have this question... probably is similar to Executing scripts from a database project in visual studio
but i didn't understand the solution given.
So i made a Database Server 2008 project inside visual studio.
Just one table. When i press DEPLOY the database is created inside SQLServer2008 and the table is created.
Now what if i would like to give the project to someone who has SQLServer and he needs to recreate the database and the table in his computer?..
Apart form executing the query from Visual Studio is there any way to create an executable that automatically "deploy" from outside Visual Studio?..
Thanks,
There are different types of Database projects in Visual Studio. The old ones, which were not so feature rich. The 'Data Dude' ones that came with Visual Studio 2010 Team Database Edition and the most recent iteration that comes with the SQL Server Data Tools. All of these can be installed on top of the standard Visual Studio Professional and don't require additional licenses.
SQL Server Data Tools is the latest, and also the best integrated and most powerful variant of the bunch. It can also be used to compare existing schema's and generate upgrade scripts or automatically upgrade the schema in an existing database for you.
During build, a package will be created that holds all the schema information for your database. You can then use the command line tools provided by the SQL Server data tools or MSDeploy to deploy your compressed schema file to a new or an existing database.
This deployment mechanism can also upgrade existing schema if needed.

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 :)

How Do I Attach a SQL Server Express Database to a Visual Studio 2010 project?

How do I do this?
Attach an SQL Server Express Database to a Visual Studio project so that...
my source control contains the most resent schema for the database including stored procedures (can'
t use SQL Compact Ed. because need to be able write stored procedures against the database),
can be version controlled using TFS without using tools like Red Gate Source Control,
can be automatically set up/updated when a developer gets the latest version of a project (using MS Build or similar build script api),
(would be nice) can be published after entire project passes unit tests.
Is any of this possible and if so how do I do it?
Sounds like you want a migration framework, more than you want to store the actual database. Look into migration libraries for .Net like FluentMigrator.
This sounds like continuous Database Integration:
http://www.codeproject.com/KB/architecture/Database_CI.aspx

SQL Server Management Studio solution vs Visual Studio Projects

Almost all of our projects involve a web application or winforms application and a data access layer (class library) and stored procedures/database scripts.
We are looking for a good way to organize the solutions, and found a few ways:
1)We could have a sql server management studio solution for all the db related things, then have a visual studio solution for the application and data access layer projects.
2)We could do it all in visual studio with 3 projects, a sql server project, a web app/winforms app project, and a data access layer project.
3)We could do it all in visual studio with 2 projects, a web app/winforms app project and a data access layer project, and just put the sql scripts in a directory in the data access layer project.
I'm sure there's other ways, but I'm just curious to see how others go about doing it.
I have done this successfully using Visual Studio Team System Database Edition - multiple types dot net projects with a database project in a single solution.
Keep in mind that deploying a database project takes much longer because you usually need test data and most inserts thereto are RBAR insert statements. We used to turn off deploying the database project until absolutely necessary (usually once or twice a week).
Of course, all of this was in TFS for source code control
SQL Server Management Studio solution
allow use GUI designer for creating and editing some objects.
Visual Studio Projects
allows use TFS as version control and more integrate work of all developers working with a database;
better implements IntelliSence
I use Management Studio and some batch files to export/import/store the sql in the solution (under source control too).
So each time there's a change in the db it's exported to the solution and a custom tool is run to update the ORM proxy classes.

Resources