Learn T-SQL Commands with Samples
Skip Navigation Links
Skip Navigation Links.
Expand DatabaseDatabase
Expand TableTable
Expand ViewView
Expand Stored ProcedureStored Procedure
Expand Data FilteringData Filtering
Expand Data GroupingData Grouping
Expand JoinsJoins
Expand TriggerTrigger
Expand CursorCursor
Expand OperatorsOperators
Expand ConstraintsConstraints
Expand FunctionsFunctions
Expand Conditional ProcessingConditional Processing
Expand LoopingLooping
Expand Error HandlingError Handling
Expand v.IMP Queriesv.IMP Queries
Expand XMLXML
Expand Query PerformanceQuery Performance
Expand QueriesQueries
Expand NormalizationNormalization
Collapse CreateCreate
     

User

 
      USE myDB;
      GO

      
---- Create a login using a Windows user
CREATE LOGIN [domain\windows_user] FROM WINDOWS WITH DEFAULT_DATABASE = myDB;
---- Add the user to the database using their login name and the user name
CREATE USER [domain\windows_user] FOR LOGIN [domain\windows_user] WITH DEFAULT_SCHEMA = Production; GO
---- Grant specific access rights to use based on Schema
GRANT DELETE, EXECUTE, INSERT, SELECT, UPDATE, VIEW DEFINITION ON SCHEMA::[Production] TO [domain\windows_user];