Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a SQL Server view in a specific database [duplicate]

This is a very stupid question, but I cant seem to add a view to a specific database, it gets added to the default master, which is no acceptable.

I have tried this in SQL Server 2008:

 CREATE VIEW MyDB.Test AS     
  Select Orders.CustomerID    
  From Orders

I get the error msg:

The specified schema name "MyDB" either does not exist or you do not have permission to use it.

Thanks!

like image 271
Herman Avatar asked Feb 15 '23 02:02

Herman


1 Answers

if you do have access try:

Use MyDb
Go

CREATE VIEW Test AS
Select Orders.CustomerID
From Orders
like image 160
asantaballa Avatar answered Feb 18 '23 10:02

asantaballa