Search notes:

SQL Server: login

Create a login with a password

Create a login with a password and grand unlimited access on a database.
create login [foo-bar-baz] with password = 'X$!…'

--
-- MUST go to database!
--
use tq84_db;

create user user_01 for login [foo-bar-baz] 
 
grant control on database::tq84 to user_01;

Create login with Windows authentication

Create a login with Windows authentication and grant (only) select on (only) a table.
create login [domain\user.name] from windows;

select
   suser_sname(sid) user_of_sid,
   type_desc,
   default_database_name,
   create_date
from
   sys.server_principals
where
   name = 'domain\user.name'

--
-- MUST go to database!
--
use tq84_db;

create user rene for login [domain\user.name]

select
   dp.name,
   dp.type_desc               ,  -- WINDOWS_USER
   dp.authentication_type_desc, -- WINDOWS
   dp.create_date
from
   sys.server_principals   sp join
   sys.database_principals dp on sp.sid = dp.sid
where
   sp.name = 'domain\user.name'
   
grant select on some_table to rene;

See also

database_principals,
server_principals,

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1788424426, '216.73.217.21', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/SQL-Server/administration/security/login/index(92): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78