Visual Studio 2013 database project- DROP objects in target but not in project - sql

I am using VS 2013 for database project. I want to drop ojected from target db which are not in db project including table and SP's. I have checked property "DROP objects in target but not in project" but it doesn't work. I still see table in target which is not part of db solution. I do not see any warnings either and btw table is empty so it should be dropped without warnings anyway. I have used same option in older version of Visual studio and it worked.
Any suggestions?

I know this is a long time coming to answer the question, but this is how I resolved the problem. I simply opened the SQL File TableName.sql
Ctrl+a (aka select all)
Compare
It will show the file with an action to delete in the compare
Update
Delete the file from Visual Studio 2013 project

Related

VS2022 Database Project Reference Keep Breaking

Vs2022, I have a database project. Within that project are some views and functions which refer to a system database. So I have added those system database references, both Master and MSDB to the project. The references work, all is good.
I close the solution and reopen it, and now the project shows two references to each database, and a bunch of script errors because an unresolved reference exists:
So the fix is again to remove these 4 references, add the database reference back to master and msdb, and then all is good, until I reopen the solution again!
One side note, this solution was originally created in VS2019. Also, this happens on 2 separate machines. I'm running VS 17.3.3 64-bit.
For anyone facing the same problem, VS 2022 adds two references to the DBs, one from VS extensions folder and the other one from SQL Server folder, its definitely a bug and happens often when updating VS 2022.
However, the solution is to delete the second one from the project references (SQL Folder Reference) and then you need to click on the project and explicitly save it by using Ctrl+S, otherwise, the change will not be saved and whenever you close and open the solution, the project will show invalid references.

Can't get SQL code working on Visual Studio

With the exception of a little HTML/Javascript, I've always used C++ on Visual Studio C++ 2010. I have an internship next week that will involve the use of SQL and .Net. I'm currently reading a book on SQL and it instructs us to go to its website to download code so that we can practice. The website is here: http://forta.com/books/0672336073/ I downloaded the one labeled "Microsoft SQL Server" which is basically two .sql files. One creates a simple database and the other one populates it.
However, for the life of me I cant figure out how to do it on Visual Studio 2010 or 2013 (I downloaded the full version of 2010). If anyone knows how to get these file to run on either VS version I would be very happy. I'm used to just hitting the green arrow button in Visual Studio C++ 2010, which I believe is execute. Obviously it isnt working for my sql code.
On VS 2013 I created a new "SQL Server Database Project". I then added two new "Application Role" items for the two .sql files. Now after clicking the "SQL" tab and "Execute" I get error messages about duplicate objects/keys, which I assume means the database is already created...but how do I view it? At one instance I mustve hit the right combination of buttons because I was able to view my database in a table format.
Thanks for any suggestions!
In visual studio go to view and select sql server, (see image) then click the + symbol and connect to the server installed on your machine (if its not yet listed)

How to rename table using SSDT in Visual Studio

I am using visual studio 2013 and trying to learn local database operations. I have created a database using VS and create tables. But I cannot rename table names. There is no such a option anywhere or I cannot see. I searched but find nothing.
Could anyone show me how to rename table using 'VISUAL STUDIO 2013 SSDT'
Open the table, highlight the table name in the T-SQL portion of the window, click the SQL menu, then choose Refactor and Rename. You probably want to preview changes while you're at it to see what will be affected.

Visual Studio 2013 SQL Query and View Designer not appearing

Not sure why the Query and View Designer is not appearing as per
http://msdn.microsoft.com/en-us/library/vstudio/ms172013.aspx
It's an ASP.net project with database in the AppData folder, and a connection using SQL 2008 Express.
If it helps the connection string is:
Data Source=.\SQLEXPRESS;AttachDbFilename="C:\folders...\App_Data\database.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True
If I open the project in VS2012 (where I've worked on this project for some time), find a table, right click, new query, I get the nice interactive visual design tool.
If I open the project in VS2013 (just installed) and do the same, blank page named SQLQuery1.sql and a basic connection to SQL Express (ie. master, model, etc.)
MS page tells me Tools / Options / Visual Database tools - but this doesn't exist on my installation!
Am I missing something?
Also tried with blank project, added App_Data and a new database (so using LocalDB), added a table, right click, new query - exactly the same blank file.
I have been having the same problem and think I have found the solution.
When you are adding the connection to the Database, in the Add Connection Dialog.
Click 'Change...' next to the Data source
Dialog opens showing 'Change Data Source'
You probable have selected 'Microsoft SQL Server' and then below that there is a drop down where you can select:
.NET Framework Data Provider for OLE DB
.NET Framework Data Provider for SQL Server (This is probably selected by default)
try changing to the OLE DB connection.
Click OK, and then complete the rest of the connection on the 'Add Connection' dialog.
I have then found that using the database works as it did in VS2012 and as you are describing above.
Was searching for a solution to a similar issue. Unable to use Query Designer for a local mdf file database. This is what I found...hope it helps someone.
Reading the comments here (http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ed4675d3-aa84-47db-bdf5-f852355409e6/query-designer-not-displaying-in-visual-studio-2013?forum=ssdt).
According to the moderator of that forum question (Kevin Cunnane of Microsoft), "in Visual Studio 2013 the query designer and database diagram features are no longer available from the Server Explorer. If you wish to keep using the query designer, the only other workaround for now is to access it from SSMS. "
My current workaround is to use Visual Studio 2012 Server Explorer to view data and write queries for a local MDF file. And to use Visual Studio 2013 for everything else.
I have researched about 5 minutes how to run a query in Visual Studio. At the end I found this:
Even though i followed same steps , It did not work at once it gave some error and Studio closed. It was problem at my end and unknowingly it got sorted out on its own.
This component is called "SQL Server Data Tools". You can download it from MSDN. I found this page simply by googling "vs2013 ssdt". It seems that what TsugaSoft posted is true, however you still can install this component separetely... And it also works for Visual Studio 2012.

update script when comparing Visual studio database project to schema file

I have created a database schema file of a customers database. I want to compare this schema file to my database project i Visual Studio 2010 to be able to script the schema changes that needs to be done to the customer database in connection to the upgrade of our client program.
For filesize matters I want to use this schema file (23MB) rather than getting a full database copy (1352 MB when zipped) from the customer.
I have no problem comparing the Visual Studio project to the schema file (no error messages or warnings) but I find no means to get the resulting update script. The error I am getting when pressing "Refresh update script" is: "you cannot write updates to the target when you compare the specified types of schema models". All export options are disabled.
Of course I understand that I can't write updates to the database schema but that is not my intention - I want to run the update script on the database at our customers server.
Is there any way I can get out the update script?
Thanks!
I solved it by taking a few extra turns:
I created an empty database on our local sql-server.
I compared the schema from our customers database with the empty database as target in Visual Studio and updated the empty database with the change script created by Visual Studio.
I compared the updated database with the new database schema from TFS.
The new change script I got from Visual Studio was deployed to our customers database.
Hope this helps someone, at least I learnt from it (and will hopefully remember this until the next release).