I am trying to create a powershell script to publish a database from a database project in visual studio and one of the things I would like to do is show the publish preview you get from visual studio before actually publishing the database. When using visual studio if you open the publish profile and click publish it generates this preview and then publishes the database without any pause or wait. You can also get this preview if you use the generate script feature. What I'm looking for is a way to generate this preview without generating the script or automatically publishing to the database regardless of what the preview says. I know you can use the deploy report via the command line but I was hoping to be able to use the preview since it is easier to read than the xml file. Is there a way to just generate this preview?
The answer, unfortunately, is no. That output is not otherwise available.
Related
I’m really confused with how to use database projects in Visual Studio (2019).
I’ve created a new project and imported my database into it. I then can happily edit the SQL and commit it into source control, however, when I try to deploy the items to the server it fails due to unresolved references.
To get around this I have added in a reference to my database and changed the SQL to use the reference like so:
SELECT * FROM [$(DataBase)].dbo.TableName
The project then builds and I can deploy the SQL to my server with:
Tools> SQL server > New Schema Comparison
However what do I then do if I want to edit that SQL and make any changes?
Currently I’m using the “open by default” feature to open the SQL into SSMS (as the editor in visual studio does not appear to have the ability to execute the sql), and then find and replacing the [$(Database)] text with my database name, then making and testing my changes and then cut and pasting it back into Visual Studio and find and replacing the [$(database)] text back in.
I can’t help but think that I'm surely missing something here‽ I find it hard to believe that the workflow is this longwinded.
i have developed application using vb.net for windows system. which have sql server 2008 database and also includes crystal reports. and i want to create .exe of project. For distribution.Then how can i do that. Please help.. I am trying to do this with visual studio 2010.. Using traditional method...
1.Go to File | Add and click New Project.
2.In the Add New Project dialog box, select Other Project 3.Types and choose the Setup And Deployment Projects folder..and so on..till adding project output and primary output.but after clicking on primary output it give message like..The following files may have dependencies that can not be determinited automatically. Please confirm that all dependencies have been added to the project c:\windows\system32 \macromed\flash\flash.ocx.. Please help me to solve this..
Your question and your error arent related.
For your client, you need to install Sql Express.
LocalDB deployment on client PC
For the flash error, you need to check where you are using flash and make sure is also installed.
The goal is to wire up a target or command (e.g. arbitrary executable) to be run after a database project is successfully published from within Visual Studio 2012 user interface using the Publish menu option from the database project context menu (by right-clicking the database project in Solution Explorer and selecting Publish). We have an existing, custom data loader program that bulk loads data from XML files (dumped from master databases) and it would be very convenient to continue using this existing approach. We cannot use the post-deployment SQL file to load data because it will take far too long to load and is difficult to maintain (manual). The data we are loading is a large amount of configuration data that is required by the application and is not the transactional data of the application (which is even larger).
We are currently using Microsoft Visual Studio Ultimate 2012, 11.0.60610.01 Update 3 and SQL Server Data Tools 11.1.30618.1. The database project was created using the database project template in VS2012 (.sqlproj). We are publishing to both SQL Server 2008 R2 and SQL Server 2012. We do know about the SSDT MSBuild targets file that is included in the sqlproj file and its contents. It seems that none of the Deploy or Publish targets defined in this file are executed by VS2012 during a "Publish" command. The Build targets, however, are executed when the project is built from within VS2012.
Here's what we have tried so far with no luck (each item below was attempted one-at-a-time, in isolation):
Wired up the executable command to the PostPublishEvent (similar to the PostBuildEvent).
Wired up the executable command to the PostDeployEvent (similar to the PostBuildEvent).
Wired up a new, custom target that depends on the AfterPublish target that executes the command.
Wired up a new, custom target that depends on the AfterDeploy target that executes the command.
Override the AfterPublish target in the sqlproj file.
Override the AfterDeploy target in the sqlproj file.
Override the SqlPublish target in the sqlproj file.
If I use any of the above "Publish" methods and execute the Publish target using MSBuild, everything works as expected. If I use the "Publish" user interface command in VS2012, the custom command is never executed. If I wire up the custom command to the PostBuildEvent, it runs via MSBuild and VS2012.
It seems that VS2012 is using different means to publish database projects and is not wired into the SSDT MSBuild targets except for the Build target.
Is there a clean way to wire up an arbitrary command that is executed after the "Publish" command, invoked from the VS2012 user interface, completes, ideally, successfully?
I am also aware of this post, Publish data with SSDT?, but this is not an acceptable approach relative to the existing methods used before VS2012.
Thanks!
I've looked into this too.
From what I can tell, when you use Publish... from the VS 2012/2013 context menu, VS is instantiating a SSDT SqlPublishTask directly, rather then using the common system definitions, presumably so they can integrate it into the "Data Tools" window.
Only solution I can think of is to write an extension that provides a (context) menu item, which would allow you to invoke MSBuild with the target of your choice. The Extension SDK reference seems to have everything you need to get started, while the MSBuild API reference can be found on MSDN.
(A quick search revealed no such existing extension.)
Unfortunately, I don't have access to VS Pro, so can't DiM :(.
I have a SQL project in my .Net project in Visual Studio 2010. I added it to my solution because I thought it will help me to create all the database objects in more environment without difficulties.
My scope is to create/define the database objects (tables and stored procedures) in more computers, easily.For this purpose I created an Sql project in visual studio and I added for each table and stored procedure the creation script in this project. Now I have 30 scripts and I'd like to run it on a new sql instance.
If I open each sql file I have, in visual studio, an toolbat that allows me to tun the opened file on a sql instance (I have an connect button) and this generates the proper object (table or SP).
The question is: how do I do to run all the files in this project in one click. How to create all the objects in one click? Now I have about 30 scripts to run, and I need a proper way.
The way I tried to do it was to set as default project the sql project and to press run (F5), but then I got some strange compilation errors in sql files, errors witch didn't was there when I run (execute) each script individually.
Here is the right click menu for this project (No Run, Publish or something else!):
I tried to use from that menu the Deploy command. The bad news (for me) is that I got this on that command:
I don't have any error in my sql scripts, each one runs correctly.
Thank you.
Use need to deploy your project onto a database thus use the Deploy menu item.
The way database projects work, is that they compare the schema in the project to the schema at the destination.
What this means is you shouldn't have an use statements, or alter statements, ect...
What does one of those procs look like that is throwing the error?
I am getting trouble to use Build solution in Visual Studio.
I was building data cube and I needed to use Build solution to finalize my project.
However, I couldn't find Build solution from the Build menu.
For example ....
http://cfile7.uf.tistory.com/image/18493D524E2CF5A31F8B61
It should be like this then I can choose build solution option
However, when I tried on my laptop...
http://cfile8.uf.tistory.com/image/16493D524E2CF5A21E9D27
I was unable to find these options...
I am not really sure about my mistakes....
My data was built by SQL Server 2008 R2 and I was using Visual Studio (which came with SQL Server)
Does anybody know solution to this problem?
From the second screenshot that you posted, it looks like you don't have a solution open, just the project that was contained in the solution. A Visual Studio solution file is usually a .sln file, and if you open it up in Notepad you'll see that it's just an XML file which describes project(s) it contains (the actual project files are different, the solution just makes reference to the project filenames). Make sure you get the .sln file to your laptop and open that, not the project file.
Right click on the solution or Project node which is on the Solution-Explorer. There should be Build menu item.
Or may be the Visual Studio coming with SQL 2008 R2 doesn't have that functionality?