I am in the process of putting my notes into web pages, please keep checking in later for more contents
mssql certification 70-467     70-467     20467    

Quick Search


search term:      
   



Install And Configure


Install and configure
 Plan installation
  Evaluate installation requirements; 
  design the installation of SQL Server and its components (drives, service accounts, etc.); 
  plan scale-up vs. scale-out basics; 
 plan for capacity, including if/when to shrink, grow, autogrow, and monitor growth; 
  manage the technologies that influence SQL architecture (for example, service broker, full text, scale out, etc.); 
  design the storage for new databases (drives, filegroups, partitioning); 
  design database infrastructure; 
  configure a SQL Server standby database for reporting purposes; 
  Windows-level security and service level security; 
  Core mode installation; 
  benchmark a server before using it in a production environment (SQLIO, Tests on SQL Instance); 
  choose the right hardware 
 Install SQL Server and related services
  Test connectivity; enable and disable features; 
  install SQL Server database engine and SSIS (not SSRS and SSAS); 
  configure an OS disk
 Implement a migration strategy
  Restore vs detach/attach; 
  migrate security; 
  migrate from a previous version; 
  migrate to new hardware; 
  migrate systems and data from other sources
 Configure additional SQL Server components
  Set up and configure all SQL Server components 
     (Engine, AS, RS and SharePoint integration) in a complex and highly secure environment; 
  configure full-text indexing; 
  SSIS security; 
  filestream; 
  filetable
 Manage SQL Server Agent
  Create, maintain, and monitor jobs; 
  administer jobs and alerts; 
  automate (setup, maintenance, monitoring) across multiple databases and multiple instances; 
  send to "Manage SQL Server Agent jobs"

Maintain instances and databases


Maintain instances and databases
 Manage and configure databases
  Design multiple file groups; 
  database configuration and standardization: autoclose, autoshrink, recovery models; 
  manage file space, including adding new filegroups and moving objects from one filegroup to another; 
  implement and configure contained databases; 
  data compression; 
  configure TDE; 
  partitioning; 
  manage log file growth; 
  DBCC
 Configure SQL Server instances
  Configure and standardize a database: autoclose, autoshrink, recovery models; 
  install default and named instances; 
  configure SQL to use only certain CPUs (affinity masks, etc.); 
  configure server level settings; 
  configure many databases/instance, many instances/server, virtualization; 
  configure clustered instances including MSDTC; 
  memory allocation; 
  database mail; 
  configure SQL Server engine: memory, filffactor, sp_configure, default options
 Implement a SQL Server clustered instance
  Install a cluster; 
  manage multiple instances on a cluster; 
  set up subnet clustering; 
  recover from a failed cluster node
 Manage SQL Server instances
  Install an instance; 
  manage interaction of instances; 
  SQL patch management; 
  install additional instances; 
  manage resource utilization by using Resource Governor; 
  cycle error logs

Optimize and troubleshoot


Optimize and troubleshoot
 Identify and resolve concurrency problems
  Examine deadlocking issues using the SQL server logs using trace flags; 
  design reporting database infrastructure (replicated databases); 
  monitor via DMV or other MS product; diagnose blocking, live locking and deadlocking; 
  diagnose waits; 
  performance detection with built in DMVs; 
  know what affects performance; 
  locate and if necessary kill processes that are blocking or claiming all resources
 Collect and analyze troubleshooting data
  Monitor using Profiler; 
  collect performance data by using System Monitor; 
  collect trace data by using SQL Server Profiler; 
  identify transactional replication problems; 
  identify and troubleshoot data access problems; 
  gather performance metrics; 
  identify potential problems before they cause service interruptions; 
  identify performance problems; 
  use XEvents and DMVs; 
  create alerts on critical server condition; 
  monitor data and server access by creating audit and other controls; 
  identify IO vs. memory vs. CPU bottlenecks; 
  use the Data Collector tool
 Audit SQL Server instances
  Implement a security strategy for auditing and controlling the instance; 
  configure an audit; 
  configure server audits; 
  track who modified an object; 
  monitor elevated privileges as well as unsolicited attempts to connect; 
  policy-based management

Manage Data



Manage data
 Configure and maintain a back-up strategy
  Manage different backup models, including point-in-time recovery; 
  protect customer data even if backup media is lost; 
  perform backup/restore based on proper strategies including backup redundancy; 
  recover from a corrupted drive; 
  manage a multi-TB database; 
  implement and test a database implementation and a backup strategy 
     (
      multiple files for user database and tempdb, 
      spreading database files, 
      backup/restore
     ); 
  back up a SQL Server environment; 
  back up system databases
 Restore databases
  Restore a database secured with TDE; 
  recover data from a damaged DB (several errors in DBCC checkdb); 
  restore to a point in time; 
  file group restore; 
  page level restore
 Implement and maintain indexes
  Inspect physical characteristics of indexes and perform index maintenance; 
  identify fragmented indexes; 
  identify unused indexes; 
  implement indexes; 
  defrag/rebuild indexes; 
  set up a maintenance strategy for indexes and statistics; 
  optimize indexes (full, filter index); 
  statistics (full, filter) force or fix queue; 
  when to rebuild vs. reorg and index; 
  full text indexes; 
  column store indexes

 Import and export data
  Transfer data; 
  bulk copy; 
  bulk insert

Implement security



Implement security
 Manage logins and server roles
  Configure server security; 
  secure the SQL Server using Windows Account / SQL Server accounts, server roles; 
  create log in accounts; 
  manage access to the server, SQL Server instance, and databases; 
  create and maintain user-defined server roles; 
  manage certificate logins
 Manage database security
  Configure database security; 
  database level, permissions; 
  protect objects from being modified; 
  auditing; 
  encryption
 Manage users and database roles
  Create access to server / database with least privilege; 
  manage security roles for users and administrators; 
  create database user accounts; 
  contained login
 Troubleshoot security
  Manage certificates and keys; 
  endpoints

Implement high availability



Implement high availability
    Implement AlwaysOn
        Implement AlwaysOn availability groups; 
        implement AlwaysOn failover clustering
    Implement replication
        Troubleshoot replication problems; 
        identify appropriate replication strategy



Server And Database Audit


SQL Server Audit  
sql server audit


USE Master Create server audit C_Audit TO APPLICAION_LOG ALTER SERVER AUDIT C_Audit WITH (STATE=ON) USE Contoso CREATE DATABASE AUDIT SPECIDICATION C_AuditSpec FOR SERVER AUDIT C_Audit ADD ( UPDATE On Sales.ProductPrices By dbo ) ALTER DATABASE AUDIT SPECIFICATION C_AuditSpec WITH (STATE=ON) -- ------------------------------------- CREATE SERVER AUDIT [Test_Audit] TO FILE ( FILEPATH = N'C:\AUDIT\' ,MAXSIZE = 100 MB ,MAX_ROLLOVER_FILES = 90 ,RESERVE_DISK_SPACE = ON ) WITH ( QUEUE_DELAY = 1000 ,ON_FAILURE = CONTINUE ) GO USE TEST GO CREATE DATABASE AUDIT SPECIFICATION [Test_Audit_DB] FOR SERVER AUDIT [Test_Audit] ADD (DATABASE_PRINCIPAL_IMPERSONATION_GROUP), ADD (DATABASE_OBJECT_CHANGE_GROUP), ADD (SCHEMA_OBJECT_CHANGE_GROUP), ADD (DELETE ON DATABASE::[TEST] BY [dbo]), ADD (INSERT ON DATABASE::[TEST] BY [dbo]), ADD (UPDATE ON DATABASE::[TEST] BY [dbo]), ADD (SELECT ON DATABASE::[TEST] BY [dbo]) WITH (STATE = ON) GO select * from sys.database_audit_specifications; eg: You provide temporary securityadmin access to User1 to the database server. You need to know if User1 adds logins to securityadmin server-level audit action group: SERVER_ROLE_MEMBER_CHANGE_GROUP eg: to write messages to the Application Log when users are added to or removed from a fixed server role in Serever01. A Server Audit Specification

Policy Based Management


sample policy location: 
Drive_letter:\Program Files\Microsoft SQL Server\100\Tools\Policies\DatabaseEngine\1033
Drive_letter:\Program Files\Microsoft SQL Server\110\Tools\Policies\DatabaseEngine\1033

import these sample policies (you can delete them later if you don't want to use them) 
from SSMS by navigating to Management, opening up Policy-Based Management , 
right-clicking on "Policies", then selecting "Import Policy". 

eg: a Policy: to prevent users from disabling server audits in Server01

simple talk
mssqltips

Encryption


TDE: transparent data encryption

create master ket (master)
create certificate with master key ( master)
create database encryption key (db)
backup certificate (best practice)
turn on encryption

mssqltips

Encryption Hierarchy

Master Key

-- -------------------------------
-- setup and backup:
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'MyPassword1!';

CREATE CERTIFICATE TDE_Certificate WITH SUBJECT = 'TDE Certificate';

BACKUP CERTIFICATE TDE_Certificate TO FILE = 'd:\TDE_Certificate.cer'
WITH PRIVATE KEY (FILE = 'd:\TDE_Certificate.key', 
ENCRYPTION BY PASSWORD = 'MyPassword1!');

CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_256
ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate;

ALTER DATABASE Orders SET ENCRYPTION ON;

-- restore or create new one from backup
CREATE CERTIFICATE TDE_Certificate
FROM FILE = 'd:\TDE_Certificate.cer'
WITH PRIVATE KEY (FILE = 'd:\TDE_Certificate.key', DECRYPTION BY PASSWORD 'MyPassword1!');

-- -------------------------------

CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'password';

BACKUP MASTER KEY TO FILE = 'path_to_file' 
    ENCRYPTION BY PASSWORD = 'password'

USE mydb;
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'sfj5300osdVdgwdfkli7';

BACKUP MASTER KEY TO FILE = 'c:\temp\exportedmasterkey' 
    ENCRYPTION BY PASSWORD = 'sd092735kjn$&adsg';
GO 

Certificate USE MYDB; CREATE CERTIFICATE mycertname ENCRYPTION BY PASSWORD = 'pGFD4bb925DGvbd2439587y' WITH SUBJECT = 'Sammamish Shipping Records', EXPIRY_DATE = '20201031'; GO select * from sys.certificates; USE MYDB BACKUP CERTIFICATE mycertname TO FILE = '', ENCRYPTION BY PASSWORD='' msft

AlwaysOn And Failover CLuster




CREATE AVAILABILITY GROUP [SQLAG01]   
FOR DATABASE [Crap1], [Crap2], [Crap3]  
REPLICA ON 
N'SQLVM01\AGNODE1' WITH (ENDPOINT_URL = N'TCP://SQLVM01.darling.com:5022',  
FAILOVER_MODE = AUTOMATIC,  
AVAILABILITY_MODE = SYNCHRONOUS_COMMIT,   
BACKUP_PRIORITY = 50,   
SECONDARY_ROLE(ALLOW_CONNECTIONS = READ_ONLY),   
SEEDING_MODE = AUTOMATIC),
N'SQLVM02\AGNODE2' WITH (ENDPOINT_URL = N'TCP://SQLVM02.darling.com:5022',   
FAILOVER_MODE = AUTOMATIC,   
AVAILABILITY_MODE = SYNCHRONOUS_COMMIT,   
BACKUP_PRIORITY = 50,   
SECONDARY_ROLE(ALLOW_CONNECTIONS = READ_ONLY),   
SEEDING_MODE = AUTOMATIC),   
N'SQLVM03\AGNODE3' WITH (ENDPOINT_URL = N'TCP://SQLVM03.darling.com:5022',   
FAILOVER_MODE = MANUAL,   
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,   
BACKUP_PRIORITY = 50,   
SECONDARY_ROLE(ALLOW_CONNECTIONS = READ_ONLY),   
SEEDING_MODE = AUTOMATIC);   
GO

ALTER AVAILABILITY GROUP [SQLAG01]
ADD LISTENER N'SQLAGLISTEN01' (
WITH IP ((N'123.123.123.13', N'255.255.255.0')), PORT=6000);
GO

-- -------------------------------------------------
:CONNECT SQLVM02\AGNODE2
ALTER AVAILABILITY GROUP [SQLAG01] JOIN
GO
ALTER AVAILABILITY GROUP [SQLAG01] GRANT CREATE ANY DATABASE  
GO
-- ---------------------------------------------------
:CONNECT SQLVM03\AGNODE3 
ALTER AVAILABILITY GROUP [SQLAG01] JOIN
GO
ALTER AVAILABILITY GROUP [SQLAG01] GRANT CREATE ANY DATABASE  
GO
-- ----------------------------------------------------

simple talk


https://www.google.com/search?q=70-465


msdn1 

http://searchsqlserver.techtarget.com/feature/Whats-new-in-2016s-SQL-Server-AlwaysOn-Availability-Groups

http://www.sanssql.com/2016/02/configuring-alwayson-availability.html
http://www.sanssql.com/2016/02/configuring-alwayson-availability_18.html

https://msdn.microsoft.com/en-us/library/hh213244(v=SQL.110).aspx
https://blogs.msdn.microsoft.com/sqlgardner/2012/07/21/sql-2012-alwayson-and-backups-part-2-configuring-backup-preferences-and-automating-backups/

https://www.mssqltips.com/sql-server-tip-category/143/alwayson-availability/
https://www.mssqltips.com/sqlservertip/2869/configure-sql-server-2012-alwayson-availability-groups-readonly-routing-using-tsql/

https://www.mssqltips.com/sqlservertip/2519/sql-server-alwayson-availability-groups--part-1-configuration/
https://www.mssqltips.com/sqlservertip/2518/sql-server-alwayson-availability-groups--part-2-availability-groups-setup/

http://www.sqlshack.com/alwayson-availability-groups-how-to-setup-ag-between-a-clustered-and-standalone-instance-part-1/
http://www.sqlshack.com/alwayson-availability-groups-how-to-setup-ag-between-a-clustered-and-standalone-instance-part-2/
http://www.sqlshack.com/alwayson-availability-groups-how-to-setup-ag-between-a-clustered-and-standalone-instance-part-3/
http://www.sqlshack.com/alwayson-availability-groups-curiosities-to-make-your-job-easier-part-4/

http://www.sqlshack.com/understanding-backups-on-alwayson-availability-groups-part-1/
http://www.sqlshack.com/understanding-backups-on-alwayson-availability-groups-part-2/

Contained Database


contained database:

execute sp_configure 'contained database authentication', 1
reconfigure

Execute the ALTER DATABASE statement along with CONTAINMENT=PARTIAL.

Execute sp_migrate_user_to_contained for each user

Azure



You plan to migrate the db to azure. 
You verify that all objects are valid for azure sql database. 
You need to ensure that users and logins are migrated to azure. 
What should u do?

* Use the SQL Management Studio to deploy the db to azure.

Blocking Session



sp_who 60  -- show blocking session
sp_who2 60

SELECT * FROM sys.dm_exec_sessions WHERE sessionid = 60

Database Engine Tuning Advisor


dta

Database Engine Tuning Advisor: dta -?

dta -S YourServerNameYourSQLServerInstanceName -E -D AdventureWorks2012 ^
   -if MyScript.sql -s MySession2 -of MySession2OutputScript.sql -ox MySession2Output.xml -fa IDX_IV -fp NONE -fk NONE  


Extended Event Session


mssqltips

sqlblog 
xevent 31 days

SQL Server Management Studio 
--> View 
--> Show Extended Event Session Explorer 
--> system_health
--> Events
--> sqlserver.error_reported or sqlserver.xml_deadlock_report

SELECT CAST(xet.target_data AS XML) FROM sys.dm_xe_session_targets xet 
JOIN sys.dm_xe_sessions xe 
ON (xe.address = xet.event_session_address) 
WHERE xe.name = 'system_health';


Q: You administer a Microsoft SQL Server 2012 database. Users report that an application that
accesses the database displays an error, but the error does not provide meaningful information.
No entries are found in the SQL Server log or Windows event logs related to the error. You need to
identify the root cause of the issue by retrieving the error message. What should you do?

A. Create an Extended Events session by using the sqlserver.error_reported event.

CREATE EVENT SESSION [system_health]
ON SERVER
ADD EVENT sqlserver.error_reported(
 ACTION (package0.callstack, sqlserver.session_id, sqlserver.sql_text,
        sqlserver.tsql_stack)
 WHERE (([severity]>=(20) OR ([error]=(17803) OR [error]=(701)
        OR [error]=(802) OR [error]=(8645) 
    OR [error]=(8651) OR [error]=(8657) OR [error]=(8902))))),
ADD EVENT sqlos.scheduler_monitor_non_yielding_ring_buffer_recorded,
ADD EVENT sqlserver.xml_deadlock_report,
ADD EVENT sqlos.wait_info(
 ACTION (package0.callstack, sqlserver.session_id, sqlserver.sql_text)
 WHERE (([duration]>(15000) AND ([wait_type]>(31) AND ([wait_type]>(47) 
AND [wait_type]<(54) OR [wait_type]<(38) OR [wait_type]>(63) 
AND [wait_type]<(70) OR [wait_type]>(96) 
AND [wait_type]<(100) OR [wait_type]=(107) OR [wait_type]=(113) OR [wait_type]>(174) 
AND [wait_type]<(179) OR [wait_type]=(186) OR [wait_type]=(207) OR [wait_type]=(269) 
        OR [wait_type]=(283) OR [wait_type]=(284)) OR [duration]>(30000) 
        AND [wait_type]<(22))))),
ADD EVENT sqlos.wait_info_external(
 ACTION (package0.callstack, sqlserver.session_id, sqlserver.sql_text)
 WHERE (([duration]>(5000) AND ([wait_type]>(365) 
AND [wait_type]<(372) OR [wait_type]>(372) 
AND [wait_type]<(377) OR [wait_type]>(377) 
AND [wait_type]<(383) OR [wait_type]>(420) 
AND [wait_type]<(424) OR [wait_type]>(426) 
AND [wait_type]<(432) OR [wait_type]>(432) 
AND [wait_type]<(435) OR [duration]>(45000) 
AND ([wait_type]>(382) 
AND [wait_type]<(386) OR [wait_type]>(423) 
AND [wait_type]<(427) OR [wait_type]>(434) 
AND [wait_type]<(437) OR [wait_type]>(442) 
AND [wait_type]<(451) OR [wait_type]>(451) 
AND [wait_type]<(473) OR [wait_type]>(484) 
AND [wait_type]<(499) OR [wait_type]=(365) OR [wait_type]=(372) OR [wait_type]=(377) 
    OR [wait_type]=(387) OR [wait_type]=(432) OR [wait_type]=(502))))))
ADD TARGET package0.ring_buffer(
 SET max_memory=4096)
WITH (MAX_MEMORY = 4096KB, EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS,
    MAX_DISPATCH_LATENCY = 30 SECONDS, MAX_EVENT_SIZE = 0KB,
    MEMORY_PARTITION_MODE = NONE, TRACK_CAUSALITY = OFF, STARTUP_STATE = ON)

SQL Server Browser Service


SQL Server Browser Service

deny a permission


permission and security:
deny

deny 1:
GRANT SELECT ON SCHEMA::Test TO TestRole;
GO 
DENY SELECT ON OBJECT::Test.TestTable TO TestUser;
GO

deny 2:
deny select on schema::testschema1 to testuser1;
grant select on object::testschema1.tst to testuser1;

SQL Server Management Studio


In SQL Server Management Studio, 
right-click the database, 
select Properties, and 
then click Files. 
Open the Transaction log Autogrowth window and set the maximum size of the file.

traceon


Examine deadlocks
DBCC TRACEON(1222, -1 )
Run the DBCC TRACEON 1222 command from a query window and review the SQL Server event log.

To view the Windows Event log, go to Administrative Tools, Event Viewer.
the SQL Server error log

DBCC TRACESTATUS which will pull details of which trace is currently active.

File Initialization


1): configure Instant File Initialization
2): ensure that Data File Autogrow operations use Instant File Initialization.
a): Add the CONTOSO\SQLService account to the Perform Volume Maintenance Tasks local security policy.
b): Restart the SQL Server Service.

Backup And Restore


backup or restore continue after errors

BACKUP DATABASE AdventureWorks2012
 TO DISK = 'Z:SQLServerBackupsAdvWorksData.bak'
   WITH CHECKSUM, CONTINUE_AFTER_ERROR;
GO

RESTORE DATABASE AdventureWorks2012
 FROM DISK = 'Z:SQLServerBackupsAdvWorksData.bak'
   WITH CHECKSUM, CONTINUE_AFTER_ERROR;
GO

Restore Pages 
page level restore 

page level restore 

-- file ID of file xxx is 1
RESTORE DATABASE database PAGE='1:57, 1:202, 1:916, 1:1016'  FROM <file_backup_of_file_B>   WITH NORECOVERY;  
RESTORE LOG database FROM log_backup   WITH NORECOVERY;  
RESTORE LOG database FROM log_backup   WITH NORECOVERY;   

BACKUP LOG database TO new_log_backup;   
RESTORE LOG database FROM new_log_backup WITH RECOVERY;  
GO  

dmv


DMVs:
sys.dm_tran_locks
sys.dm_os_waiting_tasks
sys.dm_exec_requests

Index


Implement and Maintain Indexes

Identify Fragmented Indexes
sys.dm_db_index_physical_stats

Identify Unused Indexes
sys.dm_db_index_usage_stats

Identify Useful Indexes
sys.dm_db_missing_index_detailes
sys.dm_db_missing_index_columns

affinity mask


Affinity Mask: CPU(Processor) and I/O Affinity

affinity mask

Column Store Indexes


 Column Store Indexes