I've deployed a database project to my local SQL Server Express - how do I see the database now? - sql

I've created a "Database project" (.dbproj project file) in Visual Studio 2008, added a couple of tables there and selected "Build->Deploy". Visual Studio said it has successfully deployed my Database1.sql into (local)\SQLEXPRESS.
Now I'd like to see the database - be able to delete it or just see that it looks right - but I can't find where the database is and how to manipulate it without writing code. How can I get a hold on the newly created database?

You can use the SQL Server Management Studio stand alone application, or the Server Explorer in Visual Studio.
There are also a lot of tools from other vendors like Toad or SQuirreL...

Related

Can not compare Azure database in Visual studio 2022 schema compare

I'm trying to compare the Azure SQL Managed instance to my local database project. But when I make a selection of the database "Ok" button is not getting enabled.
This used to work a month ago but all of a sudden it stopped working.
It's an issue with only one Azure SQL Managed Instance. We have one more Azure SQL Managed instance which is working alright(We can compare successfully).
And also it's just with Visual Studio, I have tried Visual Studio 2019 as well. We can compare alright in 'Azure Data Studio'.
Same issue with MI. Fixed by manually editing SchemaCompare.scmp file. Just add your source module section:
<SourceModelProvider>
<ConnectionBasedModelProvider>
<ConnectionString>Data Source=db.database.windows.net;Initial Catalog=aaa;Persist Security Info=False;User ID=xxx;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Interactive"</ConnectionString>
</ConnectionBasedModelProvider>
</SourceModelProvider>

EntityFramework 7 database already exists error on migrations

ASP.NET 5 project, Entity Framework 7. Using all the default stuff that comes with the ASP.NET 5 web template for creating the Identity Context. When I start up the app and first try to hit the context (register or log in), there is an error on Database.AsRelational().ApplyMigrations() that the database already exists. However, when I connect to the database matching the connection string in config.json, I do not see the database.
"ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=aspnet-myAppDb;Trusted_Connection=True;MultipleActiveResultSets=true"
Connect to (localdb)\mssqllocaldb in SQL Server Management Studio, delete the database there. I'm not sure why this step is required or why the migrations fails, however.
There is an already accepted answer, but I prefer doing this from Visual Studio. This is caused by manually deleting the MDB file. For future reference, you should not delete the MDB files from Explorer, but instead use Visual Studio or SQL Server Management Studio to delete them.
In Visual Studio, hit Ctrl+\, Ctrl+S to bring up SQL Server Object Explorer. If your keybindings are different, look under the View Menu.
Expand the node for the type of localdb you are using, find your problem database, right click and delete. Problem fixed.

SQL Management Studio attach database: Cannot open "Add" dialogue

When I press the Add... button in the Attach Databases window I get the following error:
TITLE: Microsoft SQL Server Management Studio
------------------------------
Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
The server principal "callisto\dotancohen" is not able to access the database "model" under the current security context. (Microsoft SQL Server, Error: 916)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.1750&EvtSrc=MSSQLServer&EvtID=916&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
The mention of "current security context" led me to believe that this is a permissions issue. However, when I open SQL Management Studio as Administrator I can in fact open the Add... dialogue but it will not let me browse to the C:\Users\dotancohen directory in which my database .mdf file is stored.
This is with SQL Management Studio 2012 RC0 on Windows 7 32 bit. The database .mdf file that I am interested in opening is a 2012 file and 2008 will not open it (my connect.Open() statement fails with 2008, works with 2012). Thank you.
Note that I am not interested in opening SQL Management Studio as administrator to access the database, but rather I am interested in resolving the issue with the user-opened SQL Management Studio to access the database as a regular user. My C# application running in debug mode can open this database without escalated privileges.
It turns out that this is a known bug with SQL Management Studio 2012, or at least the Beta and RC0 version.
By the way, here is the link to file bugs against Microsoft products. Not all MS products can have bugs filed against them at all times, so if the product that you need to file an issue is unavailable for bugs at the moment, try again in a month or two.
It is some MYSQLSERVER agent issue, I just restarted my VM/Machine and it started working perfectly.

Visual Studio causes error in SQL Management Studio

This is my first try of Visual Basic 2010 Express, though I have 10 yrs+ experience in VBA.
I'm running Windows XP SP2 on a desktop pc with following installed:
Visual Basic 2010 Express... just installed!
SQL Server 205 Express ... been running on pc for 12 months
I've created a new DB in SQL for my test application, but have not added any users or permissions to it as I'm using Windows authentication.
I've created a new Windows Forms Solution in VB2010EXP and tried adding a new Data Source for my new SQL DB, but it keeps giving error message about not having rights ot the db.
2 days of searching on the web has confirmed many others with similar issues, but no obvious solution. Eventually I find a few threads about permissions and moving the mdf into the root of the HDD, so try moving my mdf file up closer to the root of the Hard Drive
msf was in C:\Documents and Settings\_SharedData\Application_Data\MSSQL2005\Data\
now in C:\SQL2005\Data\
Now I can finally add a data source to my Db and start to use VS.
Problem is now occasionally when I am workng in VB and then go to the SQL Management Studio and try and view/change my DB, it gives an error and I cant access my DB. I then have to detach and re attach to my DB before I can work on it.
So my questions are:
Surely the location of my MDF file
should not be critical???
Do I need to add a user and
permission to my DB or should VB be
able to deal with this automatically
as I'm using windows authentication
Are then any known issues with
VB/VS causing errors in SQL
Managment Studio?
Thanks in advance
Grant
SQL Server runs on a different Windows Account to the one you use. You can check this by going to services (Run > Services.msc) and under SQL Server, go to properties and the Log On tab. I think by default 2005 uses the 'Network Service' system account. Now the reason you can't attach an MDF sat inside your documents folder is that account doesn't have access to your documents. You could give it permission, but you're much better off having the databases closer to the root as you have done.
Your connection to the database is driven by the connection strings you use. My personal preference is to create SQL Login accounts for my applications, and give them the least possible permissions they require. You could do the same using a Windows Account if you prefer.
I'm sure there are a couple. What is the error you are getting that prevents you accessing the Db? If we can see this error we may be able to help better.
Hope that helps.

SQL Server Management Studio -- where is Tools/Import and Export settings menu?

In Visual Studio, there is an Import and Export settings wizard which you can use to customize Visual Studio and save settings to a .settings file.
Do we have something like it in SQL Server Management Studio?
I'm constantly switching between several VM's and configuring each SSMS is a pain in the neck. I want to be able to save my settings to a file, then import it in all my VM's.
Thank you.
Tools/Import and Export settings menu option disappeared from my menubar too (both for 2005 and 2008 SSMS versions), but I had and used it on my previous machine.
For now I copy my archived settings to destination like c:\Documents and Settings\gg\Moje dokumenty\SQL Server Management Studio Express\Settings\CurrentSettings-2008-09-30.vssettings.
And it works.
The Studio keeps it's settings in the registry *HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server[version of SQL Server]\Tools\Shell*. For your scenario you could export appropriate settings on one computer and deploy the reg file to any other.
Hope it helps!
Looks like MS has (essentially) acknowledged that, if this did exist, it's gone and there are no firm plans to bring it back...
From Microsoft Connect
Hi Doug, Thank you for your suggestion
to import/export settings for the R2
release. We will not be considering
this for R2. We have this request
already on file and we'll look at it
for a future release beyond R2 to
address this request.
Unfortunate.
Old question, but if someone still looking for, I checked SQL 2012, Tools > Import and Export settings wizard has re-appeared. Also present in SQL 2014 and 2016.