Question

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?

Was it helpful?

Solution

Try this:

USE [your Database name]
SELECT * FROM Words

This should ensure that you are targeting the correct database.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top