I have a number of manually written scripts (.sql) for tables, views and stored procedures that are used from an ASP.NET application. These scripts drop the object and recreates them. I need a way to update the database when the scripts change without deleting the object. For example, when a column is added to an existing table that has rows in it, I would need to update this table with this extra column without losing the rows.
I need a way to "update" the database on a single click (I can hook up the changes using a batch file). Does Visual Studio support this kind of functionality?
If you get Visual Studio Team System - Database Edition 2008 - which is now bundled with "Developer Edition" for free - it handles that. Visual Studio database projects without that edition really just store the static SQL that you want to track. The Database Edition is capable of determining the 'deltas' between your SQL and what's in a target database, generating that script, and executing against your database. You do get the option of reviewing that generated SQL, but by default it is very safe [it won't run if it thinks that there will be any data lost].
Yes - it's called Database Projects.
You can define a Visual Studio Database Projects, have create and change SQL scripts inside it, and then execute those against a database connection of your choice when you need to.
See this blog post here for a great explanation, or read the whole series that the 4 guys from Rolla wrote.
Related
I'm trying to create a SQL Server database and then to use it to make a list with important stuff in it. I don't seem to make it work. I went to the toolbox, chose panel and then when I get into creating the server itself, it doesn't work as it is not showing me a server name and the database name needed for it to work. I tried to write them myself but it's still not working.
Both of them when I open the list don't show anything. I understood that is essential for it to show me things for it to work.
You could install LocalDB through the Visual Studio Installer, as part of the Data Storage and Processing workload, the ASP.NET and web development workload, or as an individual component.
After you install it, you could get it directly.
Here is the full documentation about LocalDB.
You can also refer to this set of ssdt database operation process to learn database.
I have a visual studio project which contains a database project. I create an executable which performs a software update and part of that update is to update the database. Some of the stored procedures are dependent on a linked server existing which gets created as part of the executable too. The problem is that this functionality is optional and the linked server won't connect on some client machines. But the DACPAC fails because the linked server can't connect. I am using sqlpackage.exe to deploy the .dacpac file.
Is there some way that I can deploy either all or only some of the stored procedures? Or maybe I can set a flag to ignore linked server errors? Or maybe there is an alternative method to using sqlpackage/dacpac?
One option I thought of is to convert the stored procedures that contain the linked server to dynamic SQL.
Having the database in visual studio and therefore source control is important.
Yes!
This is fairly easy to do. You can see your database project in visual studio. I would recommend removing the stored procs that are problematic and merging those back in to master. Then I would take out a feature branch and point again to the DB you have the stored procs on and use the schema compare to get those back as well (even the ones that don't work well so that you don't lose them). Push the commit up to the feature branch repo. Then,now that you have the problematic stored procs in source control + the shippable version in master-- you can go ahead and thruough visual studio "publish" through the database project into the DBs you want the selected objects.
If you haven't checked in anything to master-- you can do the schema compare and select all objects except those that are problematic and update your database project. and merge that to master. If this doesn't make sense, please comment on this answer and I'm happy to give more detail.
Well, I came across this. Still working on to implement this to solve my problem. Might help your cause too.
Download the filter from:
https://agilesqlclub.codeplex.com/releases/view/610727 put the dll
into the same folder as sqlpackage.exe and add these command line
parameters to your deployment:
/p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor
/p:AdditionalDeploymentContributorArguments="SqlPackageFilter=IgnoreSchema(BLAH)”
This will neither deploy, drop or alter anything in the BLAH schema.
More details on
https://the.agilesql.club/2015/01/howto-filter-dacpac-deployments/
My ASP.NET project is using SQL Server as the database. I am wondering if it is possible to store a temporary instance of my database so that I would only need to query once to work with the data that I need. For example, I will query the 2 tables, Person and Students with a common id. I want to be able to join the tables and use the information.
I think there are some solutions:
Store the tables in the front end and use ajax javascript to manipulate the tables information.
Store in a txt file or similar file on to the project folder as a pseudo database.
Would love to hear any ideas!
You could do worse than consider SQL Server Compact edition:
https://www.microsoft.com/en-za/download/details.aspx?id=17876
Which has a small footprint and supports private deployment of its binaries within the application folder
EDIT:
It seems CE is deprecated since last I used it. and MS now recommend SQL Server Express Local DB
https://learn.microsoft.com/en-gb/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-2017
And there is also SQLLite: https://www.supinfo.com/articles/single/6941-an-aspnet-core-mvc-app-with-sqlite-and-entity-framework
We have a foxpro application that is still in use. I am creating new user interfaces to the data as a first step to trying to migrate away from foxpro. We don't have the code for the GUI--I can get at the tables and views in the VFP IDE.
I can access the data externally using a linked server in Sql Server 2005 or datasets in Visual Studio 2010. I can see all the Foxpro tables in but not the views.
Is there any way to see and use the views in the linked server or dataset?
If the views are built into the database container (i.e. local views) you can see them by opening the database via the command window 'open database (name)', 'modify database' you can then see the views and just copy the sql statement and create the same thing in your new app. I don't think you can directly call the views, but I could be wrong. I haven't used built in views in several years now, it's all mostly SQL select statements that are easily used in other languages.
Or in the VFP ide add the database to a project and then view and grab the code from there.
I need to manipulate some tables in a JET database housed on a web-server:
check existing indexes
change table cluster/primary key
see what tables exist
rename tables
add tables
drop tables
browse data
etc
I don't have the option of installing PlaneDisaster or Access (even if i had it) on the local machine.
I've already written a generic web-based query tool. I'd rather not have to get into writing a whole web-based database maintenance GUI. Someone must have done this already, and probably many times over.
A partial answer might be Compare'Em
http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEMscreens/CompareEM-About.htm The Pro version allows you to create SQL statements to update the Access database file. This will allow you to generate the differences between one version and a newer version.
His website isn't very clear but as I recall the price for the Pro version was $10.
As you say you have already done a generic web based query tool. The problem with JET is that you cannot connect with it as database server like you can do with one SQL server in order to process changes to tables and other maintenance procedures. Jet is is not a client/server RDBMS. You need to have an application in the server to do that for you as you already have done with your generic web based tool, or download the database to your machine. That's why you have done some procedures and locate them in the server as asp pages.
Anyway you can use JetSQLConsole, if you don't want to use Planedisaster or Access, but remember that you need always an application on the server to to the job for you
You can also use access "in your machine" and connect to a database located in a URL (http://myserver/mydatabase.mdb) but remember when you are doing this you are downloading all the database and when you save it you are uploading it again.