Feeds:
Posts
Comments

This 15 modules, level 300 course provides students with the knowledge and skills to capitalize on their skills and experience as an Oracle DBA to manage a Microsoft SQL Server 2008 system. This workshop provides a quick start for the Oracle DBA to map, compare, and contrast the realm of Oracle database management to SQL Server database management.

Module 1: Database and Instance
Module 2: Database Architecture
Module 3: Instance Architecture
Module 4: Data Objects
Module 5: Data Access
Module 6: Data Protection
Module 7: Basic Administration
Module 8: Server Management
Module 9: Managing Schema Objects
Module 10: Database Security
Module 11: Data Transport
Module 12: Backup and Recovery
Module 13: Performance Tuning
Module 14: Scalability and High Availability
Module 15: Monitoring

Reference: Pinal Dave (http://blog.SQLAuthority.com),


Expert SQL Server 2008 Encryption (Paperback)
Michael Coles (Author), Rodney Landrum (Author)


Link to Amazon

“What is your opinion on encryption? What I mean is: In a world filled with data, how do you see encryption?” This is the precise question Michael Coles posed to me on March 3rd of this year, while we were heading to Starbucks in Seattle. We were both attending the Microsoft MVP Summit there.

In the information era, security has become one of the most vital aspects of life. Although the topic may seem a little mundane, its importance cannot be overemphasized. It is the pillar of the information age and I shudder to think where we would be without it. We don’t leave our houses unlocked and risk thieves or opportunists taking off with our valuables. We also often take precautions, not only to preserve the precious, but also to avoid the sheer hassle of replacement and misuse. So too it should be with our information.

Encryption’s roots are extremely old and it has resolved numerous security problems over the years. In days gone by, couriers were entrusted with letters sealed with a royal wax stamp. If on delivery, the seal was broken, it was obvious that there had been a security breach. This very concept evolved as CRC checksum and developed into a complex algorithm.  While CRC checksum alerted the end user to the fact that content had been modified, its limitation was that it allowed manipulation of the content to occur in the first place. With encryption, only the authenticated owner can access and modify content.

In response to Michael’s question, I began to tell him what I knew about public and private keys. He looked at me doubtfully and asked me directly if I had ever used encryption in my career. My reluctant answer to this was “No”. He strongly suggested that I not underestimate its capabilities and explore its possibilities. I took his advice and have since implemented encryption for many of my clients, who are now far safer from unauthorized access to data.

To be very honest, in my experience, not many people know much about the subject beyond a little about public and private keys.  You do not often find experts discussing symmetric and asymmetric keys, which are just the tip of the iceberg. SQL Server has come a long way with regard to security. Encryption has taken on a whole new meaning in SQL Server 2008. There are many new features such as Extensible Key Management, Transparent Data Encryption, not to mention the pre-2008 ones such as cryptographic hashing, SQL CLR and many more. In performance terms, these are great enhancements.

The one exception is Transparent Data Encryption, where the whole database is encrypted. This can considerably reduce performance if the SQL Server box is not sufficiently powerful. It this is the case, it is a good time to offload all the encryption and decryption to third-party hardware. SQL Server allows third-party management of encryption and decryption through Extensible Key Management.

Extending the earlier courier analogy, consider the fact that even if our letter is secure and safe in our hands, as soon as we hand it to the courier it is exposed to risk and can be compromised. SQL Server 2008 has many new features, which secure data while it is being communicated between applications. A number of features were introduced that check whether data is manipulated during transmission.

Data is everywhere and taking in terms of Terra Bytes (TB) is the current reality. When a large amount of data needs to be handled, there are two major challenges. The first challenge is the actual encryption process and the resources needed to perform it. The second challenge is how to use the data once it has been encrypted.  In a regular database searching through TBs of data can take a very long time. Imagine how long this could take in and encrypted database?

In Seattle, Michael and I discussed these challenges and a few more subjects. The discussion lasted more than four hours. I have always known Michael to be an excellent author. He is renowned in the industry for his expertise of XML and Full Text Search. To my mind, he is an expert who has the extraordinary ability of relating complex concepts in simple terms. No matter how long, boring or complicated the topic, his delivery is always sweet, like chocolate that melts in the mouth.

Michael always addresses uncommon subjects. Perhaps his experience as a Sergeant in the army has given him the spirit to explore the unexplored.  I have never before encountered a single book on the subject of encryption for SQL Server and Michael’s will a “first”.

I recently had the pleasure of reading it and especially like the manner in which he and his co-author, Rodney, explain the significance of encryption. While many of the concepts covered are domain-specific, quite a few topics are common to all and the appendix is a “must read” for anyone planning a security strategy. One thing that really makes this book special is the fact that each module is written independently and you can find solutions by simply reading the relevant one.

I am a hands-on developer and only like books that have a lot of workable examples. With the exception of the first chapter, the book is filled with examples and hands-on experiments. The first chapter in itself is quite unique, as it not only provides a introduction to encryption, but also the very interesting history of encryption.  Even non-technical readers will enjoy this.

Summary:
It is my great pleasure to welcome this one-of-a- kind book to the SQL Server world. There is no doubt that this book is exceptional and will inspire anyone one who is ready to take their current security mechanism to the next level using encryption.

Stars : 5 Stars

Reference: Pinal Dave (http://blog.sqlauthority.com)

Introduction

Today we have a very interesting subject to look at. I tried to look for help online but have not found any other documentation besides what we have from the Book Online.

Let us try to understand what are the different kinds of hints available in SQL Server and how they are helpful.

What is a Hint?

Hints are options and strong suggestions specified for enforcement by the SQL Server query processor on DML statements. The hints override any execution plan the query optimizer might select for a query.

Before we continue to explore this subject, we need to consider one very important fact and say some words of caution. SQL Server Query optimizer is a very smart tool and it makes a best selection of execution plan. Suggesting hints to the Query Optimizer should be attempted when absolutely necessary and by experienced developers who know exactly what they are doing (or in development as a way to experiment and learn).

There are three different kinds of hints. Let us understand the basics of each of them separately.

Join Hint

This hint is used when more than one table is used in a query. Two or more tables can be joined using different kinds of joins. This hint forces the type of join algorithm that is used. Joins can be used in SELECT, UPDATE and DELETE statements.

Query Hint

This hint is used when certain kind of logic has to be applied to a whole query. Any hint used in the query is applied to the complete query, as opposed to part of it. There is no way to specify that only a certain part of a query should be used with the hint. After any query, the OPTION clause is specified to apply the logic to this query. A query always has any of the following statements: SELECT, UPDATE, DELETE, INSERT or MERGE (SQL 2K8); and this hint can be applied to all of them.

Table Hint

This hint is used when certain kind of locking mechanism of tables has to be controlled. SQL Server query optimizer always puts the appropriate kind of lock on tables, when any of the Transact SQL operations SELECT, UPDATE, DELETE, INSERT or MERGE are used. There are certain cases when the developer knows when and where to override the default behavior of the locking algorithm and these hints are useful in those scenarios.

Let us run the following simple query with different kinds of query hints and observe the actual execution plan. The analysis of execution plan is not part of this article and will be covered in future.

USE AdventureWorks
GO
/* No Query Hint */
SELECT *
FROM Production.Product AS p
INNER JOIN Sales.SalesOrderDetail AS sod ON p.ProductID = sod.ProductID
WHERE Weight = 20.77
GO
/* Merge Join Query Hint */
SELECT *
FROM Production.Product AS p
INNER MERGE JOIN Sales.SalesOrderDetail AS sod ON p.ProductID = sod.ProductID
WHERE Weight = 20.77
GO
/* Hash Join Query Hint */
SELECT *
FROM Production.Product AS p
INNER HASH JOIN Sales.SalesOrderDetail AS sod ON p.ProductID = sod.ProductID
WHERE Weight = 20.77
GO
/* Loop Join Query Hint */
SELECT *
FROM Production.Product AS p
INNER LOOP JOIN Sales.SalesOrderDetail AS sod ON p.ProductID = sod.ProductID
WHERE Weight = 20.77
GO
/* Remote Join Query Hint */
SELECT *
FROM Production.Product AS p
INNER REMOTE JOIN Sales.SalesOrderDetail AS sod ON p.ProductID = sod.ProductID
WHERE Weight = 20.77
GO

The above query will produce the following query execution plan.

In this article we will focus mainly on Join Hints. We will discuss other kinds of hints and their usage in a different article. There are a total of four kinds of join hints available.

Loop Join

This join is also commonly known as nested iteration. This kind of join is composed by an outer loop and an inner loop. When the query runs for each row of the outer loop, the inner loop is executed completely. This join is effective only when the outer loop query is small and the inner loop query has all the proper optimizations applied. This join method is very useful with small transactions.

Merge Join

This join has the unique requirement for tables involved in the operation to be sorted. This join keeps both of the tables sorted in parallel and compares each table row by row simultaneously with each other. It compares one row of the first table with one row of the second table. If they are equal, that row qualifies; otherwise, this join determines which row of each table has the lower value. Once the lowest value of the table is figured out, it moves on to next row of that table and compares that to the original row. This operation keeps going on until all rows from each table are completely examined. This operation can be very expensive when tables are not sorted and it’s required to sort them before they are joined. If tables have non clustered indexes over them and joins are using the same conditions, there are pretty good chances that this join performs better than other kinds of joins.

Hash Join

This is the most complex of all the other joins. There are two major components of this kind of join – build query and probe query. First, a smaller table is assigned as build query and a hash table for the same is created. This hash table is compared with the probe table. This comparison of input table and probe table is done one row at a time. One row of the probe table is hashed and compared against the other row, and qualifying rows are checked.

There are three different kinds of hash joins:  in-memory hash join, grace hash join, and recursive hash join. Let us look in more detail at these three kinds of joins.

In-Memory Hash Join

This kind of hash join is used when tables are very small and a complete table can be hashed and loaded in memory.

Grace Hash Join

This kind of hash join is used when tables are comparatively large and don’t fit in memory. Tables will be partitioned at input levels and processed in steps.

Recursive Hash Join

This kind of join is used for complex tables and for tables which are very large and require multilevel of table partitions.

SQL Server query optimizer is a smart tool and it knows when to use the right kind of join. When it comes to hash join, the query optimizer starts conservatively with in-memory hash join. If join is larger than in-memory it moves up to Grace hash join or Recursive hash join. Sometimes the optimizer makes a mistake in identifying a smaller table and it reverses the role of the build and probe table: this is called role reversal.

Remote Join

This is least-used tabled join ever. There is no example for it given in Book On Line. Every Join has two tables associated with it: Left Table and Right Table. The join usually happens on the Left Table. When Remote close is used, joins are performed on the site of Right Join. This join can only be performed on INNER JOIN as in case of OUTER join there may be NULL values on the right table which makes concept of joining on right table logically incorrect.

Summary

We have closely observed different kinds of Join Hints in this article. We will cover the remaining concepts in another article.

Reference: Pinal Dave (http://blog.SQLAuthority.com), DNS

It is very easy to find out some basic details of any table using the following Stored Procedure.

USE AdventureWorks
GO
EXEC sp_spaceused [HumanResources.Shift]
GO

Above query will return following resultset

The above SP provides basic details such as rows, data size in table, and Index size of all the indexes on the table.

If we look at this carefully, a total of three indexes can be found on the table HumanResources.Shift.

USE AdventureWorks
GO
SELECT *
FROM sys.indexes
WHERE OBJECT_ID = OBJECT_ID('HumanResources.Shift')
GO

The above query will give result with query listing all the index on the table.

There is a small puzzle for all of you here. The puzzle is to write a query that will return the size for each index that is listed in above query. We need a query that will return an additional column in the above listed query and it should contain the size of the index. In our case, we will have three different sizes, which should add up to a total of 40 KB as shown in earlier query, where the total size is displayed.

I will publish the solution with due credit on this blog.

Reference: Pinal Dave (http://blog.sqlauthority.com)

Script of Backup, Integrity Check and Index Optimization are the most important scripts for any developer. SQL Expert and true SQL enthusiast Ola Hallengren is known for his excellent scripts.

Please try it out and let me know what you think. The documentation is available on http://ola.hallengren.com/Documentation.html and the script can be downloaded from http://ola.hallengren.com.

Here is brief documentation sent by Ola himself for his script in his own words.

Backup Maintenance

I think that most of you have experienced the error messages “BACKUP LOG cannot be performed because there is no current database backup.” and “Cannot perform a differential backup for database “”, because a current database backup does not exist.”.

This usually happens when you have created a new database or when you have changed recovery model of a database from Simple to Full.

The consequence is that the database is not getting backed up, until a full backup (or a differential backup for the BACKUP LOG error message if that can be done) has been performed. It will also create some noise in your monitoring system.

The solution is to check if a differential or transaction log backup can be performed before doing the backup. This can be done by checking sys.master_files.differential_base_lsn and sys.database_recovery_status.last_log_backup_lsn.

The backup solution that I have developed has a parameter called @ChangeBackupType.

EXECUTE dbo.DatabaseBackup @Databases = 'USER_DATABASES', @Directory = 'C:\Backup', @BackupType = 'LOG', @ChangeBackupType = 'Y'

If it’s a new database in Full recovery model, the backup type for that database and job run will be changed to full. If it’s a database that was newly changed to Full recovery model, then the backup type for that database and job run will be changed to differential. The next time the job runs a transaction log backup will be performed for that database.

New databases start getting backed up quickly and no more “BACKUP LOG cannot be performed because there is no current database backup.” and “Cannot perform a differential backup for database “”, because a current database backup does not exist.”.

Index Optimization

The design idea is categorize all indexes based on their fragmentation level (High, Medium or Low) and whether there are columns with LOB (Large Object) data types. For each category you can define an action. The possible actions are to rebuild indexes online or offline, reorganize indexes, update statistics, reorganize indexes and update statistics or to do nothing.

Here’s an example.

EXECUTE dbo.IndexOptimize
@Databases = 'USER_DATABASES',
@FragmentationHigh_LOB = 'INDEX_REBUILD_OFFLINE',
@FragmentationHigh_NonLOB = 'INDEX_REBUILD_ONLINE',
@FragmentationMedium_LOB = 'INDEX_REORGANIZE',
@FragmentationMedium_NonLOB = 'INDEX_REORGANIZE',
@FragmentationLow_LOB = 'NOTHING',
@FragmentationLow_NonLOB = 'NOTHING',
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 30,
@PageCountLevel = 1000

Indexes with a fragmentation above 30% are to be rebuilt, online if possible (no LOB columns), otherwise offline (LOB columns). Indexes with a fragmentation between 5% and 30% are to be reorganized. Indexes with a fragmentation below 5% or a size below 1000 pages are not to be touched.

If you are using partitioning IndexOptimize has a parameter, @PartitionLevel to do index rebuilds and reorganizations on the partition level. If you prefer to do sort operations in tempdb you can do that with the parameter @SortInTempdb and if you would like to set a fillfactor you can do that with the parameter @FillFactor.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

Please try it out and let me know what you think. The documentation is available on http://ola.hallengren.com/Documentation.html and the script can be downloaded from http://ola.hallengren.com.

Update: Do not forget to checkout last three photos and follow me on twitter (of course!)

I have previously documented my four-day experience of SQL PASS 2009 Summit at Seattle. There were many reasons for SQL enthusiasts to attend the SQL PASS event; I am listing my own reasons here in order of importance to me.

  • Networking with SQL fellows and experts
  • Putting face to the name or avatar
  • Learning and improving my SQL skills
  • Understanding the structure of the largest SQL Server Professional Association
  • Attending my favorite training sessions

During these four days, there was so much happening that it is difficult to document everything. I had tried to cover this event briefly on a daily basis in the following blog posts:

SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 1
SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 2
SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 3
SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 4

I will list a few of the additional details that I have not included in the earlier post. Keynotes were the best part of the event, and I have covered major points of the keynote in above mentioned posts. I had met many SQL Legends during this event and included information regarding them. However, there were few things I still missed and I am listing them here. Seattle is great city, and I am visiting it the second time. This time I got an opportunity to take the Underground city tour and I had really enjoyed.

Washington Convention Center
Washington Convention Center
Undergroud Tour 1
Undergroud Tour 1
Undergroup Tour 2
Undergroup Tour 2

It was great to meet SQL Server MVP Glenn Berry at the MVP Summit. He is a very kind and friendly person. You will always find him hanging around with people from different organizations and countries. If you try to eavesdrop his conversation, you will hear terms like ‘dmv’, ‘performance’, and ‘optimized query’ very often. He is very much known for his excellent optimization script known as “SQL Server 2008 Diagnostic Information Queries“. If you have never taken a look at that, I urge you to go there and check this out. I believe that even if he blogs once a year only with this script, his fans will not complain. I have previously published his interview on my blog. Please note that he is the only person ever featured in an interview on this blog.

Glenn Berry and Pinal Dave
Glenn Berry and Pinal Dave

It depends! This is one most loved (or hated) phrase in the world of programmers or DBA. It is quite common to start answering question using this phrase. Mostly, this phrase initiates humor but rarely, people take this as offence. Again the intent of speaker is not always conveyed properly, it depends on how the phrase is used (I could not resist to use this phrase as well :P). I had very interesting discussion with Michelle Ufford and Jason Strate when we were waiting for coffee at one afternoon. We discussed both the sides of this phrase. Michelle suggested many good points when and why this phrase is valid. Jason also suggested that this phrase is commonly used a) when the presenter does not have sufficient information to answer or b) when the presenter does not know the answer. We discussed that it would be really interesting to start the conversation answering the most possible answer and then talking about special cases (for which it depends is quite commonly used.) Let us see one example.

Michelle Ufford, Jason Strate, Pinal Dave
Michelle Ufford, Jason Strate, Pinal Dave

Q: Does index improve performance?
A1: It depends on query and data you have.
A2: Usually YES; however, there are cases when it reduces performance, for which the query and data needs to be examined carefully.

There are times when it depends totally make sense. I use it several times; I love the blog of Andy Warren which talks is branded as it depends. This discussion between three of us was just a friendly discussion, and if you think we are talking about you, it is wrong!

During this event, I had great conversation with SQL Legend Buck Woody. This man is full of energy and may be the most loved person in this summit. His session was the funniest session I have ever attended. At the end of his session, I had more than 2 pages of my notebook filled with notes. If I have wrote down how many times, I have laughed loudly, I would have no time to do anything else. Buck had a good hour of discussion with me. We discussed many different topics, ranging from Community to Microsoft and Collage Students to SQL. I am very thankful to Buck for spending his valuable time with me – I am honored.

Buck Woody and Pinal Dave
Buck Woody and Pinal Dave

Joe Celko – this name is very popular in SQL world, and I admit that I was always afraid of him. Every time I see his photo, I just felt nervous. I never thought that I should meet him. Honestly, for the same reason, I did not attend his session. I was absolutely wrong. I met him right after his session was over. He is one of the most friendly people I have met in my life. He is very soft spoken. He gauges the level and understanding of other person and speaks at the same level. He made me laugh and taught many good techniques for how to become good speaker and presenter. When I said I was sorry that I was scared of him, he laughed and said that he knows this. Boy, what a mistake I did!! I should have attended his session. Well, at least I am accepting my mistake here. He is indeed a very friendly soul. He promised me that one time he will come to India.

Brian Moran is the newly elected board member; I would like to call him as ‘the Man with 1000 successful ideas‘. You have to come across him to know what I am talking about. I had the great opportunity to meet him and discuss few things, besides SQL. Brian had many excellent ideas about how to build the community, how to help SQL PASS and few excellent ideas about how to take PASS to the next level. I am glad that he is one of the board members for PASS. PASS is all about passion, and Brian clearly demonstrates the same.

Pinal Dave, Joe Celko, Brian Moran
Pinal Dave, Joe Celko, Brian Moran

I met all of them and had a great conversation with them. It was great to meet Ed Hackney; he is a wonderful person and very easily approachable. He talked about SQL community in India and how any community cannot be restrained within geographical boundaries.

Ed Hackney and Pinal Dave
Ed Hackney and Pinal Dave

I was waiting to meet Thomas LaRock. He is an excellent SQL Master, and he talked in detail about outsourcing SQL technology and SQL community. I really enjoyed meeting him and spending some time with him during the summit. I plan to learn more from him when I meet him next time.

Thomas LaRock and Pinal Dave
Thomas LaRock and Pinal Dave

Robert Cain, he is one of the very few SQL masters, who have expertise in .net and Business Intelligence at the same time. I have previously wrote about him in Big Thinkers – Robert Cain. He has given approval that I can write about his BI presentation on this blog. I will write about it soon.

Chris Massy, Robert Cain, Pinal Dave
Chris Massey, Robert Cain, Pinal Dave

I have previously written a lot about Greg Low on this blog. However, I just can not resist to put this excellent photo once again here. He has great respect for the international community; and he had spent some quality time with me discussing how to enhance and grow the global community. Greg gave his insight and few plan cache tips as well. You can read my review of his book ‘Book Review – The Rational Guide to Building Technical User Communities (Rational Guides)‘. You can also read our discussion on plan cache ‘SQL SERVER – Plan Caching and Schema Change – An Interesting Observation‘.

Greg Low and Pinal Dave
Greg Low and Pinal Dave

Following image is for sure very interesting! Can you recognize the person? Well, just go here and read about Mr. Denny. And I do have permission from him to publish this photo!

Mr. Danny
Mr. Danny

PASS 2010 dates are announced; this event will take place between 8 and 12 November 2010.

PASS 2010
PASS 2010

Following image is my favorite as it brings the future and past of PASS together. Kevin Kline, a hero of PASS summit, (as he dedicated 10 years of his life to serve PASS board) is in same frame with Rushabh Mehta, who is President Elect for 2010.

Past President Kevin Kline and Future President Rushabh Mehta
Past President Kevin Kline and Future President Rushabh Mehta

Now I am coming to the most interesting part of my experience. I want to introduce to all of you the youngest SQL PASS fan and follower. Her name is Shaivi Dave, and she is big fan of SQL PASS! Shaivi suggests that save your money and register right away for PASS. There is no other conference which is as valuable as SQL PASS.

Nupur Dave and Shaivi Dave
Nupur Dave and Shaivi Dave
Pinal Dave and Shaivi Dave
Pinal Dave and Shaivi Dave

She had conveyed her wish to SQL PASS President Elect Rushabh Mehta when she was just 19 days old. May be one of following years, we will see her at summit.

Rushabh Mehta, Shaivi Dave, Pinal Dave
Rushabh Mehta, Shaivi Dave, Pinal Dave

This is note is addendum to my four original posts. I strongly suggest you all to read my earlier posts for details on keynote and other SQL legends.

SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 1
SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 2
SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 3
SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 4

If you have visited this event and have something more to add to what I have written, please feel free to add it here as a comment. I am looking forward for you all to add more details and information here. Follow me on twitter.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

SQL Server 2008 Diagnostic Information Queries

Many companies are considering or have already implemented consolidation of computing resources, including Microsoft SQL Server instances and databases, in their organization. A consolidation effort is a complex task that requires information, a detailed plan and timeline for success, and a strategy for administering the consolidated environment. This white paper walks through the journey of gathering and analyzing the information to base all planning and implementation decisions on; how to plan, architect, and implement consolidation; and finally, the considerations for administering a consolidated SQL Server environment.

This white paper is based on the Microsoft Operations Framework (MOF). MOF is an iterative approach to the IT lifecycle, and it is designed to bring together both the technical and nontechnical sides of implementation and administration.

Download Whitepaper Consolidation Using SQL Server 2008

Reference: Pinal Dave (http://blog.SQLAuthority.com)

Disk partition alignment is a powerful tool for improving SQL Server performance. Configuring optimal disk performance is often viewed as much art as science. A best practice that is essential yet often overlooked is disk partition alignment. Windows Server 2008 attempts to align new partitions out-of-the-box, yet disk partition alignment remains a relevant technology for partitions created on prior versions of Windows.

This paper documents performance for aligned and nonaligned storage and why nonaligned partitions can negatively impact I/O performance; it explains disk partition alignment for storage configured on Windows Server 2003, including analysis, diagnosis, and remediation; and it describes how Windows Server 2008 attempts to remedy challenges related to partition alignment for new partitions yet does not correct the configuration of preexisting partitions.

The following topics are also included: background information, implementation, vendor considerations, two essential correlations, valid starting partition offsets, and the simple protocol to align partitions, define file allocation unit size, and assign drive letters. It includes results from tests that show how partition alignment can affect performance for SQL Server 2008.

The following topics are also included:

  • Background information
  • Implementation
  • Vendor considerations
  • Two essential correlations
  • Valid starting partition offsets

The paper also covers the simple protocol to align partitions, define file allocation unit size, and assign drive letters.

Disk Partition Alignment Best Practices for SQL Server

Reference: Pinal Dave (http://blog.sqlauthority.com)

Introduction

This article will cover the most spectacular feature of SQL 2008 – Policy-based management and how the configuration of SQL Server with policy-based management architecture can make a powerful difference. Policy based management is loaded with several advantages. It can help you implement various policies for reliable configuration of the system. It also provides additional administration assistance to DBAs and helps them effortlessly manage various tasks of SQL Server across the enterprise.

Basics of Policy Management

SQL server 2008 has introduced policy management framework, which is the latest technique for SQL server database engine. SQL policy administrator uses SQL Server Management Studio to create policies that can handle entities on the server side like the SQL Server objects and the instance of SQL Server databases. It consists of three components: policy administrators (who create policies), policy management, and explicit administration. Policy-based management in SQL Server assists the database administrators in defining and enforcing policies that tie to database objects and instances. These policies allow the administrator to configure and manage SQL server across the enterprise.

The following advantages can be achieved by appropriate administration of policy management system.

  • It interacts with various policies for successful system configuration.
  • It handles the changes in the systems that are the result of configuration against authoring policies.
  • It reduces the cost of ownership with simple elaboration of administration tasks.
  • It detects various compliance issues in SQL Server Management Studio.

Policy Management Terms

To have a better grip on the concept of Policy-based management there are some key terms you need to understand.

  • Target – A type of entity that is appropriately managed by Policy-based management. For example, a table, database and index, to name a few.
  • Facet -A property that can be managed in policy-based management. A clear example of facet is the name of Trigger or the Auto Shrink Property of database.
  • Conditions – Criteria that specifies the state of facet to true or false. For example, you can adjust the state of a facet that gives you clear specifications of all stored procedures in the Schema “Banking”.
  • Policy – A set of rules specified for the server objects or the properties of database.

Practical Example of Policy Management

Exploring of Facets

Facets are database objects and each of them is a container of one or more database object. First, you need to navigate the object explorer and expand the policy-based management node and the management node. You will see conditions, policies and facets nodes. SQL Server 2008 has many different facets available to use.

To view the list of facets, expand the facet node

Double click on each of these facets to the list of the facet properties.

Let us understand the two next elements of creating condition and creating policy with real life example of Statistics. We will try to create statistic property of the database. We have property of statistic IsAutoCreated. We can set that using database property window under option tab. This property takes two values True or False.

We will follow up on this property in different steps. We will first create condition and right after we will use the same condition in a policy. That policy will be evaluated by user. User will have to two options either let us evaluated by scheduled task or fix non complaining policy manually.

Create a Condition

Creation of condition in Policy-based management is the next thing after identifying the problem. In our case, we want to make sure that everywhere IsAutoCreate is set to True everywhere.

Each facet displays different kinds of properties. As we are interested in the IsAutoCreated property of the statistics we have to select facet as Statistic.

Create a Policy

Creating a policy is the next important task after creating a condition. The condition has to be created to select the proper property of the object. However, a policy is created to specify the location where the condition has to be applied.

Please follow the instructions given in the above image. Make sure to select all target databases. In given example I have two database installed on my server that brings up two different targets servers.

This brings up an interesting concept of targets. Targets are database objects. They can be whole database or single parts of the database. It may be possible that they are different kind of objects but have same kind of properties.

While creating a policy we have kept the evaluation mode as “on demand”, which means that we will be running this policy manually, instead of scheduled job. Scheduled job is good idea to run policy.

Evaluate a Policy

As in the previous step, we have selected to evaluate the policy manually; we will evaluate that using SSMS. Right click on policy brings up with lots of options. Select Evaluate from the menu, this will bring up the following image.

On the screen of Evaluate Policies there is a button which suggests evaluating the policies. Once clicked it will give the following kind of screen with a status.

You will see a green icon in the image. This icon indicates the policy evaluated the status to True. If you notice you will find that in our example all the policies are complied with.

Fix Non-complying Policy

Now, let us change the IsAutoCreate policy of one of test databases to true and run the evaluation all over again. If you observe you will notice that one of the statuses is marked as false with a little red image on the left.

Furthermore, once you select the checkbox and clicked on the Apply button you will find an additional checkbox on the side. This Apply button will raise a popup confirming that the property of the target has been changed to comply with the policy. Next, click Ok to confirm. This will change the properties of the Test database to comply with the new policy on all of our targets specified earlier.

In our example, we have manually evaluated the policy and fixed its noncompliance. With powershell you can perform the same using SQL Server Agent.

Summary

Policy-Based Management empowers you with greater control over the procedures of database as a Database Administrator. It provides you the ability to enforce paper policies at database level. Paper polices are used as guidelines for understanding database standards. However, it necessitates some skills, time and efforts to enforce these polices. You need to go with a fine toothed comb to enforce these policies. Policy-based management system helps you define these polices and ensure that they will be enforced appropriately.

Reference : Pinal Dave (http://blog.SQLAuthority.com), DNS

Foreign Key and Check Constraints are two types of constraints that can be disabled or enabled when required. This type of operation is needed when bulk loading operations are required or when there is no need to validate the constraint. The T-SQL Script that does the same is very simple.

USE AdventureWorks
GO
-- Disable the constraint
ALTER TABLE HumanResources.Employee
NOCHECK CONSTRAINT CK_Employee_BirthDate
GO
-- Enable the constraint
ALTER TABLE HumanResources.Employee
WITH CHECK CHECK CONSTRAINT CK_Employee_BirthDate
GO

It is very interesting that when the constraint is enabled, the world CHECK is used twice – WITH CHECK CHECK CONSTRAINT. I often ask those to find the mistake in this script when they claim to know the syntax very well.

Have you ever disabled and enabled constraints in your production environment? I would like to know why you did so.

Reference: Pinal Dave (http://blog.sqlauthority.com)

Older Posts »