DataBase project in Visual Studio - 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.

Related

Unable to publish DB project on Azure SQL Data Warehouse

With Visual Studio 2019 (already updated to the latest version), I have created a new SQL Server Database Project connected to an Azure SQL Datawarehouse Database.
I imported all the object already present on the database (tables, stored procedure and schema), I carried out the schema compare which does not detect any difference.
On the project properties I changed the Target platform setting it up on Miscrosoft Azure SQL Data Warehouse, I switched the Compatibility level setting it on SQL Server 2017 (140)
The build of solution is successful, but when I tried to publish the solution I have the following message error
Creating publish preview...
Errors occurred while modeling the target database. Deployment can not continue.
I can generate the publish script only if I check the box Always re-create database, but I don't want drop and re-create the database every time
I did a lot of research but none of them solved my problem.
Anyone knows if there are any known limitations concerning the publish of SQL Server Database Project on Azure SQL Datawarehouse Database or does anyone know how to solve the problem?
Thank you
Deploying database projects to Azure SQL Data Warehouse is in public preview since August if you use Visual Studio 2019 SQL Server Data Tools (SSDT) as documented here. At the bottom of the page Microsoft gives you instructions on how you can provide feedback directly to the SSDT team.
Database projects were not supported on Azure SQL Data Warehouse as you can read here and here.
Check your database tables in the "System Tables." If you have dbo.sysdiagrams,
that won't allow you to deploy the db.
So, if you delete dbo.sysdiagrams table on your database, that will hopefully allow you to deploy the database.
They get created when you click on the database diagrams.

How do I import the subset of a database into a visual studio 2013 project

I'm trying to upgrade a Visual Studio 2008 database project to a visual studio 2013 database project.
I've been getting an error like
[dbo].[trigger_name] has an unresolved reference to object [dbo].[table_name]
From what I've read here, it seems to say that you can import a subset of a database somehow:
SQL Server Database projects are meant to mirror fully the databases
to which their contents will be deployed. Although you can create
projects that contain just a subset of a database—for example, the
assets for a SQL CLR assembly—SSDT will block you as soon as any T-SQL
in the project references an object in the database that is not also
in your project.
Since I only need 10 tables for my script to run, how do I create these tables in my project, so that I no longer encounter the aforementioned error?
Or, is there a way to link to a database on a server and allow my triggers to verify the object against the actual database schema?
You can create a new db project then right click on it and choose Import database. In
the Import wizard you will choose which table you want to be imported.
Once you have it imported then go to your actual database project and add database reference which will point to the newly created project.
Second method is to add those 10 tables to your existing project. Right click on the project name and choose Schema Compare. Set your project as a target and Sql Server database as a source, click Compare, choose your tables and click Update target.
You can't add a reference to sql server directly.

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.

Publishing a SQL Server Database project

I've created a SQL Server database project that correctly deploys a database on my machine. However, I need this project to create databases on QA's machine. They do not know how to create a database from a script.
Is there a way a database project in Visual Studio 2010 can be published so all a non-technical user has to do is click an executable and the database will automatically install?
What you are looking for is this MSDN article: Deploying a Database by Using the Database Publishing Wizard.

Database project deployment

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

Resources