Problems setting default schema

In college, I run the following command to change my default schema:

ALTER USER [campus\s00103417] WITH DEFAULT_SCHEMA = MyCmdSet01; 

I recently installed SQL Server on my laptop under win7. Everything else works fine. But when I create a database, create a schema and try to set it by default, it gives me an error. Below is the code that I run on my laptop.

 ALTER USER [L01\Admin] WITH DEFAULT_SCHEMA = dbo; 

Below is the error that I am getting

 Cannot alter the user 'L01\Admin', because it does not exist or you do not have permission. 

What I do not understand, obviously, I exist, I created a database. I also taught me that DBO will have permission to do almost anything I like. Obviously, I do not quite understand this. Can anyone explain how I can execute the command above so that I can change the default schema.

If this is relevant, I have only one login (no password). As soon as the computer boots up, it pushes me to the desktop. Then I run SQL Server 2008 Management Studio, which asks me to connect, and I type L01 as the server name and select Windows Authentication.

Any help would be very helpful.

EDIT: I don't know if they will provide any help. I executed the commands:

 SELECT SUSER_NAME() --Output L01\Admin SELECT USER_NAME() --Output dbo 
+4
source share
2 answers

You are talking about your username (I think this is "L01 \ Admin"). This is different from the database user. If your login is in the sysadmin fixed server sysadmin , you are automatically mapped to the user of the built-in dbo database. Therefore, you do not find your user L01\Admin , because it does not actually exist.

It makes sense? Just remember: server login <> database user .

+4
source

In SQL Server, a user is a database-level object. What is your current database when running the alter command? Do you actually have a username [L01 \ Admin]?

0
source

Source: https://habr.com/ru/post/1390117/


All Articles