Reputation: 5270
I'm trying to run a simple SQL query on a LocalDb database in Visual Studio 2013.
Here's the query in a file GrabWords.sql
:
SELECT * FROM Words
where Words
is a table in the NextGen.mdf
database. When I run this, I get the error:
Invalid object name 'Words'.
For more information, I actually have two databases in the project. In the Solution explorer one is called NextGen.mdf
, and the other Cards.mdf
. In server explorer, the first (that I am trying to query) is called AutoGenEntities
and the other is CardsDBContext
.
I just want to run this query to test queries and view the database - is there another tool I should be using to do this?
Upvotes: 0
Views: 2982
Reputation: 6819
Try this:
USE [your Database name]
SELECT * FROM Words
This should ensure that you are targeting the correct database.
Upvotes: 2