- Posts tagged SQL
- Explore SQL on posterous
Securing SQL Server with Transparent Data Encryption (TDE)
If it was not clear by my recent post Auditing SQL Server, I have compliance and security on my mind lately. This post is no different.
While SQL Server has had encryption for some time, implementation takes significant planning and can require modification of application code. With SQL Server 2008, Microsoft introduced Transparent Data Encryption (TDE). This feature allows for encryption of the actual data and log files and any subsequent backups of those files. TDE avoids the need for application modification by performing the encryption and decryption in real time and at the database level.
Note: TDE is an Enterprise Only feature
Before covering how to enable TDE and encrypt the database, it needs to be noted that the certificate used to encrypt the database needs to be backed up and available in the event a recovery is necessary. This needs to be included in DR planning before TDE is enabled.
The first step toward TDE is creation and subsequent backup of the Master Key.
USE master GO --Create the Master Key Encryption CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'MyP@$$w0rd' GO --Backup the Master Key BACKUP MASTER KEY TO FILE = N'C:\SQLCertBackup\MasterKey' ENCRYPTION BY PASSWORD = 'MyP@$$w0rd' GO
Once the Master Key has been created, the Server Certificate can be created. This certificate is stored in the master database.
USE master GO --Create the Server Certifiacate CREATE CERTIFICATE MyServerCert WITH SUBJECT = 'My Certificate' GO --Backup the certificate BACKUP CERTIFICATE MyServerCert TO FILE = N'C:\SQLCertBackup\MyServerCert' GO
With the Master Key and the Certificate created, the database is ready to be secured through the creation of the database encryption key. This key is secured by the certificate created above.
--Create the Database Encryption Key USE AdventureWorks2012 GO CREATE DATABASE ENCRYPTION KEY WITH ALGORITHM = AES_256 ENCRYPTION BY SERVER CERTIFICATE MyServerCert GO
The final step is to actually enable encryption of the database.
--Enable encryption on the database ALTER DATABASE AdventureWorks2012 SET ENCRYPTION ON GO
TDE and Performance
Understanding that TDE works by encrypting and decrypting in realtime naturally leads to questions regarding performance. Microsoft BOL claims that it will only increase CPU utilization by 3-5%. Some independent testing by Rob Garrison seems to support Microsoft’s claim. You can check out his testing here.
Additional items to consider when implementing TDE:
- During the initial implementation of TDE, the entire database and log files will need to be encrypted. How long this will take is dependent upon many factors including size of the database and server specifications.
- Enabling TDE on an instance will encrypt the tempdb for the entire instance.
- Backup compression will not be as effective because encrypted data does not compress well.
- FILESTREAM data is not encrypted using TDE.
Conclusions
TDE gives the DBA a way to secure the database without having to alter applications connecting to it. It is important to understand the effects before implementing. If applications connecting to the database already cause a heavy load on the CPU it is important to test how TDE will effect performance.
If you are using TDE in production, I would love to hear about your experience in the comments below.
T-SQL Tuesday: DBA Ethics
![]()
This month’s T-SQL Tuesday is hosted by my friend Chris Shaw (Blog | Twitter) and covers DBA’s Ethics. He posed some interesting questions on the topic.
Should we have an ethics statement?
As a certified project manager from the Project Management Institute, I am already bound by a code of ethics. This code applies to all PMI members.
I think a code of ethics would be a great but how it would be implemented? It would need to be tied to an organization like PASS and then required for all PASS members to be bound to. This gives people and understanding that if the person I am talking to is a member of PASS they are bound by this code.
Have ethics issues impacted you? What did you do about it?
In Chris' article, he mentions encountering an ethical dilemma. I have faced a similar issue in the past.
At one of my clients when I was given charge of the company’s ERP database. Upon conducting an initial audit of the system I found that every user that was connecting to the company’s financials had dbo access. Some users were even encouraged to connect to the system using Microsoft Access or event SSMS to conduct their daily duties. The justification was that customizing the system cost too much because they were going to upgrade and correct access then.
I had to have a deep discussion with the CxOs about the risks of this security flaw. Even after my pleading, they were not willing to make the security changes necessary. They were not willing to make a change, citing that they were going to upgrade the system and correct the issue when they did.
While I had their response in writing, it was not enough. Working with a version of SQL Server 2008 R2 Enterprise so I enabled Auditing on the database. There was now at least an audit trail of who was accessing or making changes to the system. In the end, we were never faced with a worst case scenario but the system was not upgraded for almost 2 years.
Security Audits: how do you police what you and others are doing in the database?
There is a multi-tier approach to this question. The main response is the most obvious, implementation of the principle of least privilege.
What happens when the principle of least privilege gives a user, like a vendor, more access to the data than we are comfortable with? This is an unfortunate but realistic scenario. The only thing left here is to audit what these users are doing. This should hold true for all people with dbo or sysadmin membership.
The final tier that should be implemented is a strong change management process. This requires that changes made to the system are documented. This makes others aware of changes in the system.
Does a Code of Ethics mean anything to anyone? How do we as a community enforce a Code of Ethics?
A Code of Ethics does matter, to me at least. It establishes an expectation of how a person bound to them will act. It frames a conversation or relationship.
Do you have an issue with this Code of Ethics?
I am not sure what Chris was after with this question, and I forgot to ask him at dinner on Monday night. If he is talking about the SANS: IT Code of ethics he mentions in his article, I do have issue with the same statement he did.
I will not advance private interests at the expense of end users, colleagues, or my employer.
This does not sit well with me. Just do what is right.
What do you believe out Code of Ethics should say if we the SQL Server Community have one?
There are a couple of things I like about the PMI Code of Ethics I think should be included in an SQL Community Code of Ethics. It includes sections about responsibility and honesty. I would like to see this in a Code of Ethics that is developed.
Auditing SQL Server
“An auditor is someone who arrives after the battle and bayonets all the wounded”
It is the time of year in the United States that the word “audit” conjures up images of the Internal Revenue Service dragging us across a bed of hot coals. But that is not the case when we talk about it in reference to SQL Server. In SQL Server 2005 and earlier auditing was done through a combination of tools such as triggers, Windows logs, and SQL Trace. With the release of SQL Server 2008, Microsoft introduced auditing as a feature in the database engine to satisfy requirements around regulatory compliance including HIPPA, Sarbanes-Oxley, and PCI.

Flash forward to SQL Server 2012, auditing is a valuable addition to a DBA’s toolset. It gives us a very granular way to audit activity on a server, all the way down to specific database objects.
Auditing is made up of three components: Server Audit, Server Audit Specification, and Database Audit Specification. We will break these down and set up auditing on our “new” old friend, AdventureWorks2012.
Server Audit
The SQL Server Audit tells us where we store the audit data. This location can be either the Windows Application log, Windows Security log, or a log file. A Server Audit is specific to a single instance of SQL Server but you can have more than one Server Audit per instance. This allows administrators the granularity to store different audit information in different locations if required.
--Create a server audit called Corp_Audit in the folder C:\AuditLogs\. CREATE SERVER AUDIT Corp_Audit TO FILE (FILEPATH = 'C:\AuditLogs\'
The audit option ON_FAILURE dictates what the server should do if the file cannot be written to. While shutting down the server if the audit file cannot be reached may sound extreme, it is required by some standards or companies.
By default the Server Audit is disabled.
--Enable the Server Audit ALTER SERVER AUDIT Corp_Audit WITH (STATE = ON) GO
At this point, the Server Audit is turned on but it is not auditing anything. With the location of the audit set we can now define Server Level events to audit and database level events. We will start with Server Level events.
Server Audit Specification
Server level events like Backup, Restores, Failed Logins, etc can be audited through the Server Audit Specification. The Server Audit Specification can be created and turned on in the same command.
--Create and enable the Server Audit Specification CREATE SERVER AUDIT SPECIFICATION Corp_Server_Audit_Spec FOR SERVER AUDIT Corp_Audit ADD (BACKUP_RESTORE_GROUP), ADD (DATABASE_OBJECT_CHANGE_GROUP), ADD (DATABASE_PRINCIPAL_CHANGE_GROUP), ADD (DATABASE_ROLE_MEMBER_CHANGE_GROUP), ADD (FAILED_LOGIN_GROUP) WITH (STATE = ON) GO
Database Audit Specifications
Database level events like SELECT, UPDATE, INSERT, DELETE are tracked through the Database Audit Specification. The Database Audit Specification can also be created and enabled in the same command. The following code will create a database audit on the EmployeePayHistory table so we can find out when someone with dbo privileges queries or modifies the table.
--Create and enable the Database Audit Specification USE AdventureWorks2012 GO CREATE DATABASE AUDIT SPECIFICATION Corp_AdventureWorks2012_Database_Audit_Spec FOR SERVER AUDIT Corp_Audit ADD (SELECT, UPDATE, INSERT, DELETE ON HumanResources.EmployeePayHistory BY dbo) WITH (STATE = ON)
Now that we have the audit file set up we can perform tasks on the database. As we perform tasks the information is stored in the audit file.
Query the Audit File
We have set the audit to store information in a file instead of the Windows logs. To query the file the fn_get_audit_file function is used to query it.
--Query the audit file USE master GO SELECT * FROM sys.fn_get_audit_file('C:\AuditLogs\Corp_Audit_*.sqlaudit',DEFAULT,DEFAULT ) GO
We have coved how to set up auditing and have used some examples of audit actions. A full list of the options on both server and database level audit actions and groups can be found here. Do you have a specific auditing question? We would love to hear from you in the comments below.
References
SQL Saturday #107, Houston

This weekend we will be hosting SQL Saturday in Houston. SQL Saturday is an opportunity to gain some SQL knowledge, meet people in the SQL Community and eat some Texas BBQ. I am not sure what could make a weekend any better.
The speaker lineup is set and it has some big names on Who’s Who of SQL Server experts on it. I hope you will join us. More information about the event including registration and location can be found on the SQLSaturday Houston event page.
I look forward to seeing everyone there.
Developing Microsoft SQL Server 2012 Databases (71-464): Afterthoughts and Study Notes

I have just completed my final SQL Server 2012 beta exam. I have blogged about my experiences with the exams and this is my final one. For more information regarding my other exam experiences you can see the links below.
Querying Microsoft SQL Server 2012 (71-461)
Administering Microsoft SQL Server 2012 Databases (71-462)
Developing Microsoft SQL Server 2012 Databases (71-464) – This article
Designing Database Solutions for Microsoft SQL Server 2012 (71-465)
As I have mentioned before, I am not a developer. This test only proved even more that development is an area I need to continue to work and grow.
I created some study notes based off of the Microsoft Training Catalog. Taking 4 test in two weeks was a difficult experience to get all of this information together. This is intended to augment what you are already working on to study for the exam. It is no way complete.
I also use Evernote to take all of my notes. I have set up a shared notebook where you can see all of the notes I have taken.
Implement Database Objects
- Create and alter tables
- Temp Tables and Table Variables
- Transaction logs are not recorded for the table variables.
- More info: http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-var...
- Manage a database without triggers
- Table constraints
- More information regarding constraints: http://msdn.microsoft.com/en-us/library/ms189862.aspx
- Column constraints
- Specified as part of the column definition
- Table constraints
- Data version control and management
- rowversion
- Each database has a counter that is incremented for each insert or update operation that is performed on the table that contains a row version column within the database.
- timestamp is the synonym for rowversion but it is being deprecated
- More information can be found here: http://msdn.microsoft.com/en-us/library/ms182776.aspx
- rowversion
- Create tables without using the built-in tools
- Temp Tables and Table Variables
- Design, implement and troubleshoot security
- grant, deny, revoke
- GRANT
- More information here: http://msdn.microsoft.com/en-us/library/ms187965.aspx
- DENY
- Dated article here: http://msdn.microsoft.com/en-us/library/aa258829%28v=sql.80%29.aspx
- REVOKE
- More information can be found here: http://msdn.microsoft.com/en-us/library/ms187719.aspx
- GRANT
- Connection issues
- Execute as
- More Information can be found here: http://msdn.microsoft.com/en-us/library/ms188354.aspx
- Certificates
- Loginless users
- Contained users
- Part of contained databases
- grant, deny, revoke
- Design the locking granularity level
- Locking granularity
- More information here: http://msdn.microsoft.com/en-us/library/ms189849.aspx
- Lock Modes
- More information here: http://msdn.microsoft.com/en-us/library/ms175519.aspx
- Isolation levels
- Controls the locking and row versioning
- READ UNCOMMITTED
- Reads can be dirty
- no locks issued
- READ COMMITTED
- cannot read uncommitted data
- REPEATABLE READ
- No dirty reads
- Shared locks are placed on all data read by each statement in the transaction
- SNAPSHOT
- Ensures that data will be transactionally consistent at the START of the transaction
- SERIALZABLE
- Statements cannot read data that has been modified but not yet committed by other transactions
- No other transactions can modify data that has been read by the current transaction
- Other transaction cannot insert new rows with key values that would fall in the range of the keys read by any statement in the current transaction until it completes
- Range locks are placed on the range of key values
- More information here: http://msdn.microsoft.com/en-us/library/ms173763.aspx
- Locking granularity
- Maintain indexes
- Inspect physical characteristics of indexes
- The INDEXPROPERTY command can return the named index or statistics property
- More information on INDEXPERPERTY can be found here: http://msdn.microsoft.com/en-us/library/ms187729.aspx
- Perform index maintenance
- Columnstore Indexes
- groups and stores data for each column and then joins all the columns to complete the whole index.
- This is mainly useful in BI and data warehouse application
- More information on conlumstore indexes can be found here: http://msdn.microsoft.com/en-us/library/gg492088.aspx
- Reorganize and Rebuild Indexes
- Reorganize
- Uses minimal system resources
- Physically reorders the leaf level pages to match the logical order
- Rebuild
- Drops and recreates the index
- Enterprise only feature will allow for rebuild ONLINE. This allows the rebuild to keep the index accessible during the rebuild.
- More information on Reorganize and Rebuild Indexes: http://msdn.microsoft.com/en-us/library/ms189858.aspx
- Reorganize
- Filtered Indexes
- Can improve query performance because it is smaller than full indexes.
- Cannot have filtered index on a view
- CREATE NONCLUSTERED INDEX … WHERE
- More information regarding filtered indexes can be found here: http://technet.microsoft.com/en-us/library/cc280372.aspx
- Columnstore Indexes
- Inspect physical characteristics of indexes
- Implement data types
- CLR data type
- Impact of GUID
- Spatial data
- Geometry and Geography data types.
- More information on Spatial data can be found here: http://msdn.microsoft.com/en-us/library/bb933876.aspx
- Spatial Indexing
- Defined on a table column
- More information regarding Spatial Indexing can be found here: http://msdn.microsoft.com/en-us/library/bb964712.aspx
- LOB data types
- Large object data
- This includes TEXT, NTEXT, IMAGE, VARCHAR(MAX), NVARCHAR(MAX), FILESTREAM, XML, VARBINARY
Administering Microsoft SQL Server 2012 Databases (71-462): Afterthoughts and Study Guide

So this is the third of of the four SQL Server 2012 beta exams that I am taking. I have blogged about my experiences with the other exams and shared the study notes that I have used. This post is no different. For more information no the other exams I have taken to date, see the links below.
Querying Microsoft SQL Server 2012 (71-461)
Designing Database Solutions for Microsoft SQL Server 2012 (71-465)
The exam was pretty good. I have nit picky issues with the way some of the questions were worded but overall I felt the test did a good job of covering the material.
My study notes listed below are based off of the Microsoft Training Catalog. You will not that I did not covey everything listed in the catalog. I didn't have time to get it all listed out.
Install and Configure SQL Server (19%)
* Plan installation
* Evaluate Installation Requirements
* Drive best practices
* Disk configuration primer: http://www.mssqltips.com/sqlservertip/1328/hard-drive-configurations-for-sql-server/
* Service Accounts
* These should be Managed Service Accounts
* Install SQL Server and related services
* Implement a migration strategy
* Configure additional SQL Server Components
* Configure full-text indexing
* allows for full-text queries against character based data
* More information about configuring full-text indexing can be found here: http://msdn.microsoft.com/en-us/library/cc879306.aspx
* Configure FILESTREAM
* This can be done through the GUI or through TSQL and the sp_configure command
* More information on FILESTREAM can be found here: http://msdn.microsoft.com/en-us/library/cc645923.aspx
* Configure FileTable
* FILESTREAM must be enabled to use FileTable
* Enable Non-Transaction Access at the Database Level
* Specify a directory for FileTables at the Database Level
* More information on FileTable: http://msdn.microsoft.com/en-us/library/ff929068(v=sql.110).aspx
* Manage SQL Server Agent
* Create, maintain, and monitor jobs
* More information on creating jobs: http://msdn.microsoft.com/en-us/library/ms190268.aspx
* Monitor Jobs
* Job activity can be viewed in the Job Activity Monitor
* Job activity can also be queried by running the sp_help_jobactivity
* More information can be found here: http://msdn.microsoft.com/en-us/library/ms187449.aspx
* Administer jobs and alerts
* An alert is an automated response to an event
* Alerts can respond to
* SQL Server events
* Performance conditions
* Windows Management Instrumentation (WMI) events
* More information on alerts can be found here: http://www.simple-talk.com/sql/database-administration/sql-server-alerts-soup-to-nuts/
* Manage and configure databases
* Filegroups
* named collections of files and are used to help with data placement and administrative tasks such as backup and restore operations.
* Log files are never part of a file group
* More information regarding Filegroups can be found here: http://msdn.microsoft.com/en-us/library/ms179316.aspx
* Database configuration
* Five categories
* Auto Options
* Cursor Options
* Recovery Options
* SQL options
* State options
* More information on Database configuration options can be found here:http://msdn.microsoft.com/en-us/library/aa933082(v=sql.80).aspx
* Transparent Data Encryption (TDE)
* real-time I/O encryption and decryption of the data and log files
* It does not provide encryption across communication channels
* Encryption is performed at the page level.
* More information regarding TDE can be found here: http://msdn.microsoft.com/en-us/library/bb934049.aspx
* Database Console Commands DBCC
* More information can be found here: http://msdn.microsoft.com/en-us/library/ms188796.aspx
* Manage Log file growth
* Information regarding managing the size of Transaction Log files can be found here: http://msdn.microsoft.com/en-us/library/ms365418.aspx
* Configure SQL Server Instances
* Implement a SQL Server clustered instance
* More Information can be found here: http://msdn.microsoft.com/en-us/library/ms179530.aspx
Optimize and Troubleshoot SQL Server (14%)
* Identify and resolve concurrency problems
* Deadlock Trace Flags
* Profiler Trace Flags 1204 and 1222 return information that is captured in the error log
* More information regarding Deadlocks can be found here: http://msdn.microsoft.com/en-us/library/ms178104.aspx
* Reporting database infrastructure (replicated databases)
* Transactional replication is typically the form used for data warehousing and reporting
* More information can be found here: http://technet.microsoft.com/en-us/library/ms151198.aspx
* Monitor via Dynamic Management Views
* DMVs and DM Functions return server state information
* More information regarding DMVs can be found here: http://technet.microsoft.com/en-us/library/ms188754.aspx
* Diagnose Blocking
* Information regarding blocking can be found here: http://sqlblog.com/blogs/adam_machanic/archive/2011/04/14/blocking-blockers-and-other-b-words-a-month-of-activity-monitoring-part-14-of-30.aspx
* Collect and analyze troubleshooting data
* Monitor using profiler
* Profiler manages traces and allows for the replay of trace results
* More Information on Profiler can be found here: http://msdn.microsoft.com/en-us/library/ms181091.aspx
Designing Database Solutions for Microsoft SQL Server 2012 (71-465) Afterthoughts and Study Notes

Design Database Structure (29%)
- Design for business requirements
- Design physical database and object placement
- Log files and data should be isolated at the physical disk level
- Logical vs. physical design: http://sqlserverpedia.com/wiki/Physical_vs._Logical_Design
- Filegroups
- Database objects and files can be grouped together in file groups for allocation and administration purposes.
- This is for data files only. Log files are managed separately.
- No file can be a member of more than one file group.
- Two Types
- Primary
- User Defined
- More information regarding file groups can be found here: http://msdn.microsoft.com/en-us/library/ms179316.aspx
- Design a table and index partitioning strategy
- Partitioning can have manageability and performance benefits
- More information re: Table Partitioning: http://msdn.microsoft.com/en-us/library/ms190787.aspx
- Partitioned Indexes
- Aligned Index
- Nonaligned Index
- More information regarding Partitioned Indexes: http://msdn.microsoft.com/en-us/library/ms190787.aspx
- Design a migration, consolidation, and upgrade strategy
- Upgrade with minimal downtime
- If Mirroring or clustering is in play this can be achieved by doing rolling upgrades
- Contained Databases
- This is a database that is isolated from other databases and from the instance of SQL Server that hosts the database.
- Metadata that describes the database is maintained inside the database and not in the master database
- All metadata are defined using the same collation
- User authentication can be performed by the database
- More information on contained database: http://msdn.microsoft.com/en-us/library/ff929071.aspx
- Contained databases are extremely useful with AlwaysOn for moving databases and users.
- Design SQL Server Instance
- Affinity Masks
- The Affinity Mask will change how SQL Server accesses CPUs.
- More information regarding Affinity Mask http://msdn.microsoft.com/en-us/library/ms187104.aspx
- The IO Affinity mask is a targeted optimization
- More information on the IO Affinity mask can be found here: http://blogs.msdn.com/b/psssql/archive/2010/11/19/how-it-works-io-affinity-mask-should-i-use-it.aspx
- Clustering
- SQL Server clustering allows multiple physical servers to host a single SQL Server Instance.
- It leverages Windows Clustering technologies
- Microsoft Distributed Transaction Control
- Coordinates transactions that update two or more transaction-protected resources
- More information regarding regarding Distributed Transaction Coordinator: http://technet.microsoft.com/en-us/library/cc759136(v=ws.10).aspx
- SQL Server memory allocation
- Design backup and recovery
- More information regarding Backups and Recovery: http://msdn.microsoft.com/en-us/library/ms187048.aspx
Design Database and Database Objectives (32%)
- Design a database model
- Design a logical schema
- Design a normalized database
- Design data access and data layer architecture
- Relational Model
- Normalized data model
- Database schema
- EAV modeling
- Star-Schema
- Collation
- These are the rules that govern the use of characters for a language or alphabet.
- ANSI NULLS
- This changes the way that NULLs behave
- Based off of the ANSI SQL-92 standard
- More information regarding NULLs can be found here: http://msdn.microsoft.com/en-us/library/ms187048.aspx
- QUOTED IDENTIFIER
- Causes SQL Server to follow the ISO rules regarding quotation mark delimiting
- More information can be found here: http://msdn.microsoft.com/en-us/library/ms174393.aspx
- Design Tables
- Common Table Expressions
- Temporary result set
- Confined within a single query
- More information regarding Common Table Expressions can be found here: http://msdn.microsoft.com/en-us/library/ms190766.aspx
- Transactions
- Sequence of operations performed as a single logical unit of work
- Primer on Transactions can be found here: http://www.sqlteam.com/article/introduction-to-transactions
- Views
- Essentially a virtual table
- If the view is indexed it will become a stored set of data
- Information regarding designing views can be found here: http://msdn.microsoft.com/en-us/library/ms189918.aspx
- Temporary Tables vs. Table Variables
- Transaction logs are not recorded for table variables
- Procedures with temporary tables cannot be pre-compiled
- Primer here: http://www.sql-server-performance.com/2007/temp-tables-vs-variables/ (Note, this is reflective of SQL Server 2000 and 2005)
- Filestream
- This is a way to store unstructured data in the database but store it separate from the structured data. This means SQL Server can us the NTFS file system to store the files.
- Files are stored using varbinary(max).
- While these files are stored on the NTFS file system they should not be accessed from the file system unless the OpenSqlFilestream API is used.
- More information on Filestream can be found here: http://technet.microsoft.com/en-us/library/bb933993.aspx
- FileTable
- This is built on top of Filestream technology
- Allows windows file manipulation of SQL Server unstructured data
- Allows SQL Server functionality including full-text search and semantic search to be used and access via SQL Server management tools.
- More Information regarding FileTables can be found here: http://msdn.microsoft.com/en-us/library/ff929144(v=sql.110).aspx
- Semantic Engine
- Video on the Microsoft Semantic Engine from the SQL Server team: http://www.microsoftpdc.com/2009/SVR32
- “The Semantic Engine is a technology that enables us to mine unstructured data and query it using tools that are already familiar to SQL Server professionals. It extracts and indexes pertinent information from data sources that are presented to it through data adapters. Adapters may exist for documents, audio, video, web pages and a plethora of other unstructured or partially-structured data sources” via: http://sqlblog.com/blogs/jamie_thomson/archive/2009/11/22/microsoft-semantic-engine-uncovered-the-harnessing-of-unstructured-data.aspx
- Sequences
- SEQUENCE is similar to IDENTITY but it is not bound to a specific table. Much of the difference is in the way the Metadata is stored for the numbers.
- SEQUENCE can be used during a stored procedure.
- Values can be appended to the front of a sequence.
- More information can be found here: http://technet.microsoft.com/en-us/magazine/hh407114.aspx
- Data Compression
- Can be better for IO but will use CPU overhead
- Compression is an Enterprise edition only feature
- More Information on Data Compression can be found here: http://msdn.microsoft.com/en-us/library/cc280449.aspx
- Design for concurrency
- Design TSQL stored procedures
- Design a management automation strategy
- Design for implicit and explicit transactions
- TRY…CATCH
- This is a way to implement error handling inside of TSQL.
- When an error condition is detected inside of the TRY block, control is passed to the CATCH block for error processing.
- More information on TRY…CATCH can be found here: http://msdn.microsoft.com/en-us/library/ms179296.aspx
- COMMIT TRANSACTION
- Marks the end of a successful transaction
- Makes all data modification performed since the start of the transaction permanent
- More information on COMMIT TRANSACTION can be found here: http://msdn.microsoft.com/en-us/library/ms190295.aspx
- THROW
- Raises an exception and transfers execution to a CATCH block of a TRY…CATCH construct
- If TRY…CATCH is not available the session is ended.
- THROW is a new feature in SQL Server 2012
- It allows for error handling without the need to use the RAISERROR statement that requires the use of the sys.messages table.
- THROW error numbers need to be higher than 50000 to avoid replicating system errors.
- More inofmraiton on THROW can be found here: http://msdn.microsoft.com/en-us/library/ee677615.aspx
- More examples of THROW can be found here: http://cm-bloggers.blogspot.com/2011/02/using-new-throw-keyword-in-sql-server.html
Design Database Security (15%)
- Design an application strategy to support security
- Design security
- Schemas and schema security
- SQL Server vs. Integrated Authentication
- Integrated authentication leverages the Windows principal token in the operating system.
- This uses Kerberos security protocol
- Complexity requirements and account management is in a central location
- SQL Server Authentication cannot use Kerberos security protocol
- Is good for mixed environments that don't support windows auth.
- More information regarding SQL Server authentication can be found here: http://msdn.microsoft.com/en-us/library/ms144284.aspx
- Permissions and mirroring issues
- If both SQL servers in a mirroring scenario do not run under the same service account the service account for each server will need to be manually added to all the servers in the scenario.
- More information regarding logins and mirroring can be found here: http://technet.microsoft.com/en-us/library/ms366346.aspx
- Encryption
Querying Microsoft SQL Server 2012 (71-461) Afterthoughts and Study Notes
I have just finished the first of the Microsoft SQL Server 2012 Beta exams, Querying Microsoft SQL Server 2012 (71-461). I took them for a couple of different reasons, I feel that certifications are important and it was an opportunity for me to upgrade my current certifications.
My thoughts after finishing the exam, You don't want me to be your developer. It was a good exam by I know my strengths are in database administration and not development. There were some questions that were unclear, and some that I flat didn't know the answer of but they seemed positioned simlar to the tests from last year.
If you are intersted in taking these exams you can register for them for free here.
I have mentioned before that use Evernote for a host of things. Studying for these exams has been no different. I have created a notebook that has my links to study notes. I am going to post them here but I will share the notebook that will update as I update them. You can see the notebook here.
The notes below and in my notebook are based off of the study guide posted in the Microsoft Training Catalog.
This exam is intended for SQL Server database administrators, implementers, system engineers, and developers with two or more years of experience who are seeking to prove their skills and knowledge in writing queries. Primary responsibilities may include but are not limited to:
Create database objects (24%)
- Create and alter tables using T-SQL syntax (simple statements)
- Create and alter tables
- Tables store data in the database
- The CREATE TABLE TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms174979.aspx
- After a table is created you can change many of the options through the ALTER TABLE command.
- The ALTER TABLE TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms190273.aspx
- Create and alter tables
- Create and alter views (simple statements)
- Vies are essentially virtual tables. This virtual table is defined by a query.
- Views have a max of 1024 columns
- The CREATE VIEW TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms187956.aspx
- The ALTER VIEW TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms173846(v=sql.110).asp
- Design Views
- Create and modify contraints
- Constraints define the way the Database Engine enforces the integrity of a database.
- Constraints are preferred to using Triggers, Rules, and Defaults
- Keys are constraints
- Constraint TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms189862.aspx
- Create and alter DML Triggers
- INSTEAD OF are executed in place of the usual triggering action.
- AFTER triggers are executed after the action of the INSERT, UPDATE, or DELETE
- MSDN Library Reference: http://msdn.microsoft.com/en-us/library/ms190267.aspx
- CREATE TRIGGER TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms189799.aspx
- Triggers are a way to enforce business rules and data integrity.
- It is a special type of stored procedure that automatically takes effect.
- There are three types: DML, DDL and logon
- DDL triggers are invoked when a data definition language event takes place.
- DML triggers are invoked when when a data manipulation language event takes place in the database. This includes INSERT, UPDATE or DELETE statements that modify data.
- Logon triggers fire stored procedures in response to a LOGON event.
- They can cascade changes through related tables in a database. Constraints can do this more efficiently.
- The CREATE TRIGGER TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms189799.aspx
- The ALTER TRIGGER TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms176072.aspx
Work with Data (27%)
- Query data by using SELECT statements
- Ranking Functions
- Ranking functions return a ranking value for each row in a partition
- The Ranking Function syntax for RANK can be found here: http://msdn.microsoft.com/en-us/library/ms189798.aspx
- Join Basics
- A good primer can be found on Pinal Dave's blog: http://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/
- Except and Intersect
- Returns distinct values by comparing the results of two queries
- EXCEPT retunes and distinct values from the left query that are not also found in the right query.
- INTERSECT returns any distinct values that are returned by both the query on the left and right sides of the INTERSECT operand
- Rules
- The number and order of the columns must be the same in all queries
- The data types must be compatible
- Two NULL values are considered equal
- More information can be found here: http://msdn.microsoft.com/en-us/library/ms188055.aspx
- Dynamic SQL
- Dynamic SQL is the term used when the SQL code is generated by a program before it is executed.
- CASE
- Evaluates the list of conditions and returns one of multiple possible result expressions
- The CASE statement can be found here: http://msdn.microsoft.com/en-us/library/ms181765.aspx
- ISNULL
- Replaces NULL with the specified replacement value
- ISNULL is not a replacement for IS NULL.
- ISNULL TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms184325.aspx
- COALESCE
- Returns the first non null expression among its arguments
- Expressions involving COALESCE with non-null parameters is considered to be NULL
- The COALESCE statement can be found here: http://msdn.microsoft.com/en-us/library/ms190349.aspx
- Ranking Functions
- Implement sub-queries
- A subquery can be used anywhere an expression is allowed
- A subquery will return a single value
- More information can be found here: http://msdn.microsoft.com/en-us/library/aa213252(v=sql.80).aspx
- Implement data types
- A data type is an attribute that specifies the type of data that the object can hold.
- Data types can be created through the CREATE TYPE command or through .NET Framework
- More information on Data Types can be found here: http://msdn.microsoft.com/en-us/library/ms187752.aspx
- GUIDs can cause performance issues when they are used as the clustered index key. More information can be found from Glenn Berry here: http://www.sqlservercentral.com/blogs/glennberry/2010/03/22/why-uniqueidentifier-is-a-bad-choice-for-a-clustered-index-in-sql-server/
- GUIDs are also a larger data type than necessary.
- Implement aggregate queries
- Aggregate functions return a single value summarizing a given data set. All aggregate functions are deterministic.
- Examples: COUNT, MAX, MIN, AVG, SUM, etc
- More information on aggregate functions can be found here: http://sqlserverpedia.com/wiki/Built-in_Functions_-_Aggregate_Functions
- Query and manage XML data
- SQL Server 2012 has changed the Data Type Conversion by the XML value Method Has Changed. More information regarding this change can be found here: http://technet.microsoft.com/en-us/library/ms143359(v=sql.110).aspx
- TSQL supports a subset of the XQuery language that is used for querying the XML data type.
Modify Data (24%)
- Create and alter stored procedures
- Stored procedures accept input parameters return values
- They contain programming statements that perform operations in the database
- The CREATE PROCEDURE TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms187926.aspx
- Modify data by using INSERT, UPDATE, and DELETE statement
- Combine Datasets
- Datasets can be combined by UNION, EXCEPT, and INTERSECT
- ORDER BY is only allowed at the end of the statement and cannot be used within the individual queries
- GROUP BY and HAVING clauses can be used only within individual queries not on the final result set.
- The FOR BROWSE clause cannot be used.
- MSDN Library Reference: http://msdn.microsoft.com/en-us/library/ms191523.aspx
- Work with functions
- Apply built-in scalar functions
- Provided by SQL Server.
- Cannot be modified
- Access system information without accessing the system tables
- Used to perform common tasks like SUM, GETDATE, or IDENTITY
- MSDN Library Reference:http://msdn.microsoft.com/en-us/library/ms177499.aspx
- Apply ranking functions
- Retuns a ranking value for each row in a partition
- MSDN Library Reference: http://msdn.microsoft.com/en-us/library/ms189798.aspx
- Apply built-in scalar functions
Troubleshoot and Optimize Queries (25%)
- Optimize queries
- Statistics
- The query optimizer uses statistics to create query plans that improve query performance.
- They contain statistical information about the distribution of the values in one or more columns of a table or indexed view
- More information regarding statistics can be found here: http://msdn.microsoft.com/en-us/library/ms190397.aspx
- Query Plans
- SQL Server 2012 includes additional information over 2008R2.
- Additions to the SELECT Statement
- MemoryGrantInfo is now included
- OptimizedHardwareDependentProperties is now included
- Warnings are now included to show things that will effect plans
- Some more information can be found here: http://www.sqlservercentral.com/blogs/scarydba/2011/12/12/changes-to-sql-server-2012-execution-plans/
- Plan Guide information can be found here: http://technet.microsoft.com/en-us/library/ms190417(v=sql.110).aspx
- DMVs
- DMV information can be found here: http://sqlblog.com/blogs/aaron_bertrand/archive/2011/11/18/sql-server-2012-changes-to-system-objects-in-rc0.aspx
- Hints
- options or strategies for enforcement by the query processor.
- Join Hints
- LOOP, HASH, MERGE, REMOTE
- More information on Join Hints can be found here: http://msdn.microsoft.com/en-us/library/ms173815.aspx
- Query Hints
- More Information on Query Hints can be found here: http://msdn.microsoft.com/en-us/library/ms181714.aspx
- Table Hints
- Table Hints override the default behavior of the query
- More information on table hints can be found here: http://msdn.microsoft.com/en-us/library/ms187373.aspx
- Statistics IO
- Setting STATISTICS IO is ON the query statistics are displayed when it is run
- Statistics will show information regarding physical and logical reads.
- More information can be found here: http://msdn.microsoft.com/en-us/library/ms184361(v=sql.110).aspx
- Parameterized Queries
- TSQL that accepts parameters
- Statistics
- Manage transactions
- Evaluate the use of row-based operations vs. set-based operations
- Implement error handling
Create and alter indexes
- Index allows specific data to be located quicker.
- Indexes are on-disk structure associated with a table or view.
- There are two types of indexes: Clustered and Nonclustered
- Clustered
- Sort and store the data rows in the table.
- Like 'The Highlander', there can be only one
- Nonclustered
- Contains key values and a pointer to the data roy that contains the key
- Can have more than one.
- Clustered
- Indexes, if properly designed, can reduce disk I/O and improve system performance by reducing the use of system resources.
- CREATE INDEX TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms188783.aspx
Create and alter stored procedures
- Stored procedures accept input parameters return values
- They contain programming statements that perform operations in the database
- The CREATE PROCEDURE TSQL can be found here: http://msdn.microsoft.com/en-us/library/ms187926.aspx
Create and alter user-defined functions (UDFs)
- These functions are used to bundle code for reuse within SQL Server.
- TSQL Errors cause the function to stop.
- Benefits of UDFs
- Allow modular programming
- Allow faster execution
- Can reduce network traffic
- The CREATE FUNCTION TSQL can be found here:http://msdn.microsoft.com/en-us/library/ms191320(v=sql.110).aspx
SQLRally Dallas General Session Voting
SQLRally is going to be in Dallas on May 8th and 9th. It is going to be a great opportunity for training with 40 fantastic general sessions already selected. There are 20 general sessions slots still open and PASS has given the community the opportunity to shape what sessions are going to fill them. Voting has officially opened through Friday, February 24th at 3:00pm CT.
Reviewing the list, there are some amazing speakers on it. I am truly honored to have made the list. I have submitted my session, Adventures in Project Management under the Professional Development track. I delivered this session at SQL Saturday Austin and it was a hit.
Whether I am speaking in Dallas or not, I am looking forward to seeing everyone in the SQL Community there. Below is the link to vote for sessions, as well as some other links for SQLRally.
SQLRally General Session Voting
See you in Dallas!
SQL Saturday #97, Austin Wrap Up
Last weekend I presented Adventures in Project Management at SQL Saturday #97, Austin. This was the first time I gave this presentation and it went really well. The talk was well attended and seemed to be well received. I think the fact that no one threw any fruit at me means they liked it. You can get the slides from my presentation below.
SQLSaturday#97AustinPresentation
Wes and the SQL Saturday #97 team did a fantastic job putting the event together. From this humble speaker's perspective the event ran smoothly without a hitch. This is no easy task for a team putting on their first event. I know this from our my first hand experience putting on SQL Saturday #57, Houston. I shared our lessons learned with the Austin team and they took all of them to heart. The event was made even sweeter by the fact that Wes Brown (Blog | Twitter) was named a Microsoft MVP the morning of the event. It is hard to believe this had not happened before now. This is long overdue for everything Wes has done for the SQL Server community.
]


