1

I'm using MSSQL Studio and am connected to a SQL Server 2014 with my windows credentials (DOMAIN\user).

I just created a new view and wondered why another user could not find it:

CREATE VIEW abc AS SELECT 1 AS a

Unexpectedly this view was not created in dbo schema but in DOMAIN\user. To create the view in dbo schema I needed to execute:

CREATE VIEW dbo.abc AS SELECT 1 AS a

This kind of surprises me, for I've been creating views for ages without explicit schema and have always been created in dbo – since today.

What could be the reason?

Spock
  • 260
  • 1
  • 13

2 Answers2

1

Check under Security -> Login -> Your User - User Mapping. For all selected maps your "Default Schema" should be changed to dbo.

Denis Luiz
  • 169
  • 6
1

You can change your default schema to dbo, but as a best practice views should be scripted to include the schema. In the case of dbo, it's 4 extra characters with the period but it prevents these types of issues.

EricI
  • 3,636
  • 1
  • 16
  • 8