0

I am creating a new sql server database project in visual studio 2013. I try to create a new view as follows

CREATE VIEW [dbo].[View1]
AS SELECT * FROM Company

When I try to execute in visual studio, it return something like this.

Msg 208, Level 16, State 1, Procedure View1, Line 2
Invalid object name 'Company'.

This is what shows in the status bar.

|(localdb)\Projects (11.0 SP1)|DOMAIN\myusername (52)|MyDatabase|00:00:00|0 rows

However, when I publish the project to my localdb, the view in localdb works fine.

Does any one know whats wrong? Is it something about my visual studio settings?

  • 1
    Apparently there is no table named `Company` or you don't have the privileges to access it. –  Mar 25 '14 at 15:53
  • Would you change the `company` to `dbo.company` and tell us if the problem is solved or not. I think the default schema of the user you are authenticating with is not `dbo`. – Reza Mar 25 '14 at 16:03
  • Thank you very much for the reply. However, I already try changing company to dbo.company, still the same result. Do you know why when I publish it to localdb, the view works fine but when I try to 'execute' or 'execute with debugger' it doesn't work? The intellisense doesn't find any error with it. – user3460340 Mar 26 '14 at 17:06
  • Why are you trying to execute a view? What happens if you connect a query window to your (localdb) database and try to do a "select * FROM dbo.View1" ? – Peter Schott Mar 28 '14 at 18:18

1 Answers1

0

Right click the Code Pane and select the Connection, Change Connection... context menu items. Select the SQl Server Instance that hosts your Company entity which your View is trying to query.

Example

Nigel Belham
  • 463
  • 3
  • 12