문제

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?

도움이 되었습니까?

해결책

Try this:

USE [your Database name]
SELECT * FROM Words

This should ensure that you are targeting the correct database.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top