Since SQL Server Analysis Services 2000, the product has supported a feature called drillthrough. Drillthough enables a user to select a cell and then retrieve an underlying result set from the source data for that particular cell. This functionality provides users with the ability to get a more detailed explanation as to why a certain aggregate or cell contains the value that it does. It combines the pre-aggregated nature of OLAP with the detailed records of a relational data store.

In Analysis Services 2000 you configure the drillthough settings via the Cube Editor dialog and then going Tools->drillthrough options. You specify the tables, columns and an optional drillthrough filter. In Analysis Services 2005 you configure drillthrough settings by creating a drillthough action in the cube editor’s Actions tab. Like its predecessor, in Analysis Services 2005 you can optionally provide a filtering condition. Because the drillthrough settings are significantly different in Analysis Services 2000 compared to Analysis Services 2005/2008, this issue only applies to 2000 to 2008 in-place upgrades. I have personally tested Analysis Services 2005 to 2008 in-place upgrades with OLAP cubes that contain drillthough settings and they do in fact get migrated.

In my Analysis Services 2000 test case I am using the out-of-the-box FoodMart 2000 AS database. It contains two objects that have drillthough settings defined, the HR & Sales cubes. Upgrade Advisor will detect and alert you when it scans an Analysis Services 2000 instance which contains drillthrough settings. The Upgrade Advisor corresponding help topic simply states that ‘While drillthrough exists in Microsoft SQL Server 2005 Analysis Services, drillthrough settings are not migrated from previous versions of Analysis Services’. Since Analysis Services 2005 is not subjected to this issue the Upgrade Advisor does not report anything back when it scans an AS 2005 instance.   

Prior to performing the actual SQL Server 2008 upgrade from a SQL Server 2000 instance, make note of the existing drillthough settings. Perform the actual upgrade (we always recommend using a test machine configured to mimic your production environments to test upgrade first) and then recreate your drillthough settings in your SQL Server 2008 Analysis Services instances.

Derek Comingore

As I continue to explore how 2008 will affect an application upgraded from 2000 and 2005, one question that I get almost consistently every week is “should I upgrade from 2000 to 2005 first or jump directly to 2008?”. Sure, both are supported and of course, there is no shortage of opinions and recommendations from Microsoft and 3rd parties.

One of the better 3rd party write-ups on the subject is from Steve Jones who recommends users to skip 2005 and move straight to 2008. I’ve known Steve for a while though we typically only catch up at conferences (TechEd, PASS, etc…). Still, he’s been working with SQL Server a long time and knows what he’s talking about so it’s worth taking a peek at his article on SQL Server Central.

Of course, Microsoft too has a couple of papers on the subject that are worth reviewing. While they may sound like a gentle nudge towards upgrade to 2005 first, some of the reasons are good ones. There’s the original “Why upgrade to SQL Server 2005” paper which is ok if you really are brand new to 2005. While quite dated, the info is still relevant. The newer “SQL Server 2005 Upgrade FAQ” has the latest and greatest information including a short section on the benefits of moving to 2005 first then 2008 later. It’s a good start but IMHO, doesn’t provide enough to help the average user decide.

I really don’t believe there is a hard rule for this; it really depends on each individual deployment (yes, deployment not company). Here are a few important points to consider when trying to decide whether to first upgrade to 2005 then on to 2008 or do both in 1 step. I’ve laid them in in pros/cons format to make it easier to get most folks started but the right approach really depends on your specific deployment and what’s important to you.

Path Pros Cons
Direct to 2008 One time effort Major changes for both DBAs and developers
  One downtime window Deprecated features now removed; more intensive testing required
  Latest capabilities and security  
     
Intermediate 2005 upgrade then 2008 Smaller skills delta for DBAs and developers 50-80% repeated effort (process is reused but testing effort doesn’t change)
  Window for stabilization, tuning and removing legacy code Two downtime windows
  Faster upgrade to “supported” version Lacks latest capabilities until second upgrade cycle (may be > 1 year later)
  Potential need for “workaround code” for certain capabilities

Note the the lists is not ordered or weighted in anyway. They are just intended to get folks thinking about some of the issues involved. For example, testing efforts for a 1-step upgrade might be significantly more involved than a 2-step approach. This is because there are (a small number of) deprecated features that are fully de-supported/removed from SQL Server 2008. If you had taken a 2-step approach, you would have some time to setup alerts (use of unsupported features/command will fire an event create an entry in the SQL Server log) and phase them out gradually. With the 1-step upgrade, you’d have to hunt down every line of code including dynamic SQL to be analyzed by Upgrade Advisor or run through the Application Compatibility Testing tool.

Not purely an IT decision.
Sure, the DBAs and application admins are intimately involved since they need to handle the testing and deployment. However, there’s a fair bit of learning involved especially if you want to take advantage of Policy Based Management (aka DMF) so there’s the first involvement from the business side - training budgets. Still, the most important points, IMHO, from a business perspective are the downtime window and regulatory compliance. I’ve worked with some customers where extended downtime is schedule up to 2 years in advanced. This doesn’t leave much room for doing a lot of upgrade operations so you might have to just bite the bullet and make one big jump. On the other hand, if there are specific regulations that require you to run only products that have mainstream support, you’ll likely have to get to 2005 asap (2008 will not be available till summer).

The SP1 rule
One important point I’d like to make is about SP1. I know of a lot of companies that have this rule - no RTM deployments, wait for SP1. I used to subscribe to this rule also, a very long time ago when I helped manage some Oracle DBs and in my early SQL Server days. As of 7.0, this SP1 rule really made less sense with every release. My rationale is simple. Beta versions of SQL Server have been running in production environments for SAP customers and a bunch of Microsoft’s own internal applications (its own SAP and other business critical applications) since 7.0 and the practice continues today. If you know anything about SAP, you’d know running it in production on a beta database is no small feat regardless of how many modules you run. I don’t know of any other enterprise database that does this. So if multi-billion dollar companies can run their very complex business critical applications on beta versions of the product, I’m pretty comfortable running the released version.

If you still can’t decide after all this, do a POC. Download a copy of the AppCompat Tool, aka SSUA for SQL Server 2008 (currently slated for March release) and do your own application compatibility testing. That should give you a good idea of the effort it’ll take to upgrade your database/application which hopefully, puts you in a place to make the right decision on which path to take.

In short, there are no easy answers and your decision should not be based on features alone. Though the most common response to this question is “do you need the new features”, it is hardly the most important one. Most features can be worked around with some creative code or 3rd party applications. Downtime windows and regulatory compliance requirements are generally very inflexible. Of course, your environment might be such that neither of these apply so all you really care about are the new features. Like I said from the start, it depends on each individual deployment.

joe.

ODBC History

ODBC or Open Database Connectivity is a platform neutral, universal approach for providing an Application Programming Interface (API) to access relational database management systems. ODBC was an early modular approach to enable database access. The ODBC library itself is an independent Operating System (OS) component which acts like a bridge passing requests from the consuming application to the corresponding ODBC drivers. The various data store vendors develop their product’s ODBC drivers and then either ship those with the product and or make them available over the Internet. Microsoft designed Object Linking and Embedding Database (OLEDB) as a replacement for ODBC mainly due to the desire to support a much larger variety of data stores beyond those that are pure relational databases. A nice alternative point to this post is that we take so much for granted in today’s technological landscape. At one point in time, performing database access was not a trivial task.

In today’s world, particularly the SQL Server BI world we have a plethora of drivers and providers for accessing databases, email systems, spreadsheets you name it. Like SQL Server native extended store procedures (XPs), Microsoft is slowly (but surely) phasing out the old ODBC API. Currently, Microsoft OSs still support the ODBC platform/technology, however the higher-level components are withdrawing support. SQL Server Analysis Services (SSAS) is one such component, since SQL Server 2005, SSAS has not supported the ODBC specification. The following is a quote describing the non-support of ODBC by SSAS 2005, the entire technical article can be located here http://technet.microsoft.com/en-us/library/aa964120.aspx :

‘Microsoft SQL Server Analysis Services 2000 supported a range of OLE DB providers. In particular, it supported OLE DB for ODBC. You could configure an ODBC data source to access your database.Analysis Services 2005 provides greater functionality by providing data-source views. Because it supports different syntaxes, Analysis Services 2005 imposes stricter requirements on client libraries than does Analysis Services 2000. Analysis Services 2005 does not support Microsoft OLE DB Provider for ODBC. To access your database, you must find an appropriate version of the OLE DB provider for Analysis Services.

Besides OLE DB in Analysis Services 2005, you can use managed providers to access your relational database.’

Detecting SSAS 2000 ODBC Data Sources with the Katmai Upgrade Advisor

When you analyze a SQL Server 2000sp4 SSAS instance that contains ODBC data sources with the SQL Server 2008 Upgrade Advisor (UA) utility you will receive an advisory stating that ‘ODBC Data Sources are not supported’. As described in my previous post, this is one of the more common issues that the UA will find when analyzing Analysis Services instances. A lot of folks out there are still running on the SQL Server 2000 platform including Analysis Services.

Post Katmai Installation & Resolutions

Once you perform the SQL Server 2008 upgrade you will need to update or recreate your Analysis Services data source to use a corresponding OLEDB provider. This issue applies only to SQL Server 2000sp4 upgrades to SQL Server 2008. That being said, because of the sheer number of Analysis Services 2000 installations running in production that do in fact use the ODBC drivers this is a fairly common Katmai upgrade issue.

Derek Comingore

As Joe describes in his post ‘Upgrading to SQL Server 2008: The Next Version of SQL Server Upgrade Assistant’, Microsoft made available a very handy utility called the Upgrade Advisor (UA) to assist customers in assessing their existing SQL Server 2000 environments for upgrade to the SQL Server 2005 platform. With the arrival of SQL Server 2008 we also have access to the updated UA utility that supports analyzing both SQL Server 2000sp4 and SQL Server 2005sp2 installations (which are the supported platforms for upgrade to SQL Server 2008). The UA utility is applicable to both the relational engine as well as the SQL Server Business Intelligence (BI) components (Integration Services|Data Transformation Services, Analysis Services, and Reporting Services).

*The UA utility requires the .Net Framework 2.0 redistributable

In our testing of this utility based on the November 2007 CTP build of Katmai (CTP5) we found that the UA will allow the analysis of both local and remote instances of the BI components excluding Reporting Services. Reporting Services instances will require the UA to be installed on the report server itself. Another discovery we found from our tests is that in the CTP5 build the Reporting Services analysis does not seem to be working as designed. Integration Services is not yet supported in UA, however the tool does note that in a future CTP/build of Katmai UA will support analyzing SSIS. In addition, SQL Server 2008 will continue to support the Data Transformation Services (DTS) runtime and thus the UA allows you to analyze DTS Packages in both a SQL Server 2000 and 2005 environment. A nice bonus is the ability to analyze DTS packages stored in the file system as well. Also note that when you analyze a SSAS 2000 instance the UA utility will require the Decision Support Objects (DSO) object model.

*DTS Packages are an official deprecated feature in SQL Server 2008. You should migrate your organization’s DTS packages as soon as possible to help support future upgrades of your SQL Server environments.

The UA utility provides you with both analysis and reports. UA reports provide you with the alerts/warnings that you should consider or take action on prior to upgrading your SQL Server environments to the 2008 platform. A nice feature of the UA utility is its ability to provide the user with links directly to its alert documentation. Some of the more important UA alerts are as follows:

SQL Server Data Transformation Services UA Key Alerts

· SQL Server DTS Packages are now a deprecated feature

· To continue running and managing your existing DTS Packages, the SQL Server 2008 Backwards Compatibility Files are required (these files were required for the same reason in SQL Server 2005 platform)

· The DTS Designer Components are a required add-on if you wish to edit DTS packages in Management Studio (these files were also required for the same reason in SQL Server 2005 platform)

SQL Server Analysis Services UA Key Alerts

· VBA functions handle NULL values and empty values differently from SQL Server Analysis Services 2005

· Custom Aggregations are not migrated

· ODBC Connections are not migrated

· MDX Changes

SQL Server Reporting Services UA Key Alerts

· Custom Reporting Services extensions (DLLs) will not be moved

· Client Certificates were detected (Reporting Services 2008 does not support them)

· Reporting Services 2000 Report Server database is on a remote 2000 instance (blocks a 2000 to 2008 SSRS upgrade)

Be aware that UA cannot analyze every aspect of your SQL Server environments and thus it cannot detect every issue that could affect an upgrade. Some examples of items not analyzed by the UA are middle-tier or front-tier code containing TSQL, encrypted stored procedures, and extended stored procedures. Regardless of the UA limitations, it is a very good tool for the BI professional to leverage for prepping their environments for SQL Server 2008.

Happy Upgrading!

Derek Comingore

icon for podpress  Business Intelligence: Platform Introduction [9:13m]: Download

SQL Server 2005 introduced native database encryption with the use of encryption functions. This allowed users to secure data within the database so that even admnistrators may be prevented from viewing the data. While that is a great addition, it was not a “flip the switch” implementation. Applications had to be modified to enable this feature (although it was pretty easy to do) and you had to deal with potential performance issues. The latter is the bigger challenge as you cannot index an encrypted column so you effectively end up scanning the table with an encrypted column.

This isn’t very appealing to users who truly need the encryption capability as the column they need to encrypt is often the column which they search by. A common example is a credit card company where the credit card number is the column they want to encrypt but that is also the  column they would search when customers access their accounts or when employees need to lookup a customer. When you have hundreds of millions of accounts and need to do thousands of lookups every minute, it’s a bit of a problem.

Katmai takes this a (big) step further with Transparent Data Encryption. The concept isn’t new and at least one other major database has it. Basically, think of having a layer between the storage  engine and your disks that will encrypt data before it is written to disk and decrypt it before being read into memory. Turn it on is a lot simpler than Yukon’s encryption too. You just need to create a database encryption key and set the database encryption option on. Note that your database encryption key needs to be protected by a certificate that is protected by the database master key. This ensures it can be accessed after a restart or recovery.

Unlike Yukon’s table encryption, you don’t have the same challenges with indexes like table level encryption in Yukon. The following is a simple example for encrypting your the pubs database and a query whose plan will show an Index Seek. Not very exciting in itself but considering the past encryption technique where indexes don’t even come into play, this is pretty cool.

USE master;
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘p@55w0rd’;
GO

CREATE CERTIFICATE DBEncryptKeyCert  WITH SUBJECT = ‘DB_Encryption_Key_Cert’;
GO

USE pubs
GO
– Note that not all operating systems support AES so choose an algorithm that is supported by your OS
– SQL Server supports most common algorithm like AES, DES, 3DES, RC4, etc… See Books Online for details.

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

ALTER DATABASE pubs
SET ENCRYPTION ON;
GO

USE pubs
GO
SELECT  fname, lname, emp_id
FROM  employee
WHERE  emp_id=’A-C71970F’;
GO

Just pretend emp_id is credit card number. If you had encrypted the column emp_id (i.e. credit card number) and created the encrypt/decrypt function along with the view, triggers, etc… you’d be scanning the table just to retrieve that one row. That’s what you had to work with in 2005 (unless you had some 3rd party solution). Sure, there are several ways to reduce/avoid that but solutions typically involve some variant of storing a substring of the column (hashed or as-is) and indexing that column. Not a very viable solution for credit cards since the first 6 digits make up the credit card issuer’s identification number. A bunch of other concerns pop up and though not insurmountable technically, they do present challenges and in some cases, regulations may disallow this approach. No such concern with TDE in 2008.

So what about EFS? Well, just consider it as another option to be used as appropriate. EFS encrypts the entire file system while TDE encrypts just the database. Picking the right option depends on your transportability requirements and concerns. For example, if your company uses a centralized repository for storing ALL backups and you don’t trust those pesky Windows admins that own that repository, TDE ensures nobody can copy the backup file and restore on another SQL Server instance. It is also possible to use both but be aware of the performance and administration implications especially during recovery (EFS access then database access).

Upgrade Effort & Impact
What’s the effort to benefit from this? Well, from an execution perspective, just the few steps in the sample scripts above or you can use Management Studio. If you are upgrading a SQL Server 2005 database that is already using column level encryption, suggest you revert to plain text before the upgrade. Though they are different features, there really isn’t a need for using both. Same with those who are using 3rd party encryption products. That said, there are a few challenges in the upgrade process. For instance, you might not be allowed to store data in clear text to facilitate a simple upgrade. As such, you will need to upgrade first then reverse the process which you employed to encrypt a column using the function based approach. That means you’ll turn on TDE on the database then move the data from the encrypted column to a non-encrypted column so you can do away with the UDFs (and views if you had those). Bottom line is, this may mean a longer upgrade/migrate time window plus a longer rollback time also.

There are also other considerations to your production server. This is a database wide option and will impact other components such as the transaction log and tempdb. To ensure data is not stored unencrypted once you turn it on, the current virtual log file will be “zeroed out” and new transactions will begin on the new VLF in encrypted form. Your tempDB will also be encrypted. This means you will have performance overhead on the system initially (both CPU and disk) and alters user behaviour later (e.g. can’t snoop around in tempdb easily anymore). Another important consideration is backup. With TDE, your backups are also encrypted so make sure you backup your keys/certificates also. Else, in a disaster recovery situation, you will not be able to restore your database. These and other considerations are well documented in BOL so do review in detail.

From a planning perspective, think real hard about why you need to encrypt your database. If the only reason you can come up with is “to make it more secure”, talk to your friendly neighbourhood Microsoft engineer or trusted partner before turning this on. You might eventually still employ TDE or you may not even need it (but you’ll likely discover other security concerns). Remember, security is not just about technology. If you don’t educate your staff and users or fail to practice secure processes diligently, no amount of encryption will save your data. Flipping over keyboards and turning photo frames around on users desks STILL reveal passwords (last verified Sept 2007) and backup tapes can still be found on DBAs/operators’ desks or at the reception awaiting picking. TDE is just another layer of defense in your arsenal for specific intents and attack vectors; don’t forget the others.
 

joe yong.

Minor one but we’ve had a couple of ISVs encounter this.

 When you upgrade an existing SQL Server 2005 or 2000 database instance, the size of your “MODEL” database increases. For example, 2000 model is under 1MB while 2005 is just over. 2008 is about 2MB. The log file size increases also.

 Why is this worth noting? Well, most users will not be affected by this but if you create applications that run on portable devices whether it’s laptops or handheld devices and part of your application setup involves creating a database, you might care. Also, if your database is deployed in very tightly controlled environments as far as disk space consumption goes, you might want to care.

The problem arises when scripts are used to create these databases and like the good dev/DBA that you are, you include all the options you want including initial file sizes. If your scripts were created for a 2000 or 2005 environment and you set your minimum file size based on what you know the model DB to be in those versions, they will not work in 2005 since the file size of the MODEL database exceeds your definition.

This is not detected by Upgrade Advisor but the number of users affected by this is likely to be VERY low.  Users typically only hardcode a large file sizes (many good reasons to start big) in their CREATE DATABASE statements or leave it to the default (MODEL size). Few actually hardcode a small file size value.

If you do fall into this category, it takes under 30 seconds to fix but if you don’t, your upgraded application’s setup process will fail.

joe yong.

Most admins like to build out a fresh box when upgrading a major application like SQL Server (I do too) and based on what we’ve seen, this is a popular approach. Sure, in-place upgrades are fully supported and they are generally easier to work with since your environment and system objects are upgraded automatically. However, if your server has been running for many years, it may have accumulated more unwanted bits than you’d like or know about. That’s why fresh installs are popular and that means you’ll be upgrading SQL Server side-by-side (aka. migrate).

We will cover this subject in detail over the next weeks but one thing I’d like to share real quick is the Service Accounts used for SQL Server services. First off, “Local System” is no longer permitted. During setup, you will not be allowed to select “Local System” for your SQL Server services. This is a positive move towards a secure by default and in deployment though many users will probably have to modify their automated setup scripts for 2008 (c’mon, admit it; you use local system cos it’s convenient). Local Service and Network Service are still permitted but as mentioned in numerous best practice documents, you really should create a specific local machine account for the SQL Server service or a domain account if it needs to communicate with other servers across the network.

 Now, you can still force the use of whatever account you want (at least as of current CTP build) after installation is complete by changing the properties using the Configuration Manager (I hope nobody still uses services.msc) but that’s probably not a good idea even in dev/test environments. Remember, security is not about production servers only. Many dev/test databases use copies of production data for testing which is a good thing as it provides a “real-world” sample but that also means your dev/test databases are now storing sensitive data that may be subject to the same security rules & regulations as your production server.

 For more information about Windows service accounts and recommended practices, check out http://www.microsoft.com/technet/security/guidance/serversecurity/serviceaccount/default.mspx

joe yong.

SQL Server is a data management platform that consists of several major components. As it stands in the 2005/2008 versions of the product, SQL Server’s four main components are the relational engine, the analysis services engine (BI), Reporting Services, and Integration Services (SSIS). Upgrading an instance of SQL Server does entail the risk of application compatibility issues arising with the new version of any of these four components. There are primarily two sources of incompatibility, 1) TSQL code that is dynamically built by the application and 2) TSQL code that resides in the database in the form of a stored procedure, view, function, etc. Any upgrade strategy should address compatibility issues from both sides. In this post, I am going to focus on upgrading the relational engine and tools that you can use to improve your success. We’ve also captured some great information in our corresponding podcast on the topic.

Upgrade Paths

There are several types of upgrades that are supported for SQL Server. These include variations of side by side upgrades utilizing database restores, attaches, etc. However, the most straight forward upgrade is what is called an “in place” upgrade where the setup binaries for the new version of SQL Server are run on the machine that currently hosts the previous version. Though primarily focused on in-place upgrades, tools and ideas covered in this blog apply to side by side upgrades as well.

SQL Server 2008 supports in place upgrades from SQL Server 2000 SP4 and SQL Server 2005 SP2 . This means that if you are running SQL Server 2000 you have the option of upgrading to SQL Server 2005 today and then to SQL Server 2008 when it releases or directly to SQL Server 2008 upon release.

The Upgrade Tools and Their History

In the SQL Server 2000 time frame, there was a tool that was released called the Best Practices Analyzer for SQL Server 2000 . This tool would scan a SQL Server and identify areas for improvement of things such as schema, data types, stored procedures, and other core elements of the relational engine. This eventually became the basis for the Microsoft SQL Server 2005 Upgrade Advisor . The upgrade advisor analyzes an instance of SQL Server 7.0 or SQL Server 2000 and identifies configurations and other aspects of a database that could present a problem when upgrading to SQL Server 2005. It also presents the user with links to documentation where the identified challenge is documented. There was also a set of tools utilized internally by Microsoft called the SQL Server Database Upgrade Test Tool or SQL DUTT. This tool kit was used in the SQL Server 2005 timeframe to analyze over 300 Independent Software Vendor’s (ISV) applications. This process included running actual upgrades on the ISV’s applications in a lab environment, taking the learnings from labs, and re-incorporating the learnings from the uprade into SQL DUTT. Scalability Experts actually ran the ISV labs for Microsoft and collaborated with Microsoft in incorporating the learnings from the labs into SQL DUTT. In the end, both Microsoft and Scalability Experts entered into an agreement that allowed Scalability Experts to license the IP obtained during this work and provide it via a free downloadable tool to the public. The result is The SQL Server Upgrade Assistant.

SQL Server Upgrade Assistant

The SQL Server Upgrade Assistant (SSUA) is a tool made available as a free download from Scalability Experts. The tool can be downloaded at the following link: http://www.scalabilityexperts.com/default.asp?action=article&ID=43 . SSUA uses traces to allow an IT professional to evaluate the behavior of an application on different versions, service pack levels, editions, or configurations of SQL Server. The tool can even be used to test the behavior of different version of an application release when a hotfix or service pack is installed on SQL Server. You can listen to the podcast below for further info on how SSUA can be of assistance to your organization. You can also visit the official site of SSUA at http://www.scalabilityexperts.com/default.asp?action=article&ID=43 where you can find FAQs and much more.

SQL Server Upgrade Assistant currently supports upgrading SQL Server 7.0 and SQL Server 2000 to SQL Server 2005. In the near future, the next version of this tool will be released which will also support upgrades to SQL Server 2008. Check http://www.scalabilityexperts.com or if you’d like to get on a mailing list that will provide you an email update on the release of the next version of SSUA, go to http://newsletter.scalabilityexperts.com.

 

The following audio PodCast talks in depth about upgrading to SQL Server 2008 and the relevant tools such as SQL Server Upgrade Advisor and SQL Server Upgrade Assistant.

-Derick Schaefer

 
icon for podpress  SQL Server Upgrade Assistant [25:40m]: Play Now | Play in Popup | Download

No not, SQL Server 2008 but rather how the version numbers are tracked. Run SELECT @@VERSION or SELECT SERVERPROPERTY(’productversion’) if you’re not sure where this comes from.

 In 2005 and earlier, the version format looked something like M.mm.BBBB.rr

where

M is the major version number
mm is the minor version number
BBBB is the build number
rr is the build revision number

With SQL Server 2008, the format is now M.m.BBBB.rr where the minor version number will only display 1 zero and the revision number will only display 1 digit if it’s only a single digit revision. For example, the November CTP is 10.0.1075.23

Most of us really just cared about the major and build numbers since MS did away with .5 releases a long time ago. The build number tells us what service packs and/or hotfixes have been applied.

If your application checks for SQL Server version information during setup and has a tight dependency on the format of the string returned, remember to update your setup checker so it doesn’t disallow install for the wrong reason.

We had a few ISVs encounter this so far and while the change is a really tiny one (took a whole 30 seconds to fix) the app won’t install otherwise. Not that big of a deal but your users might get a little annoyed if your app’s setup complains about the wrong version in its error message (because it incorrectly interprets the new version number format) when users are using the right one.

 

joe yong

If I had to pick my favorite feature in Katmai, it would have to be the Resource Governor. This is something I had wanted for a long time for various reasons and was sorely disappointed when it was cut from Yukon. I’m sure Richard & Euan remember the amount of grief I gave them though it wasn’t really them who made the final cut decision (but they did own the feature back then).

Prior to SQL Server 2008 Resource Governor, there really was very little you could do to manage resources within an instance. The Windows Server Resource Manager controls Windows processes so all you’re doing is restricting what the sqlservr.exe process could consume. Max/min memory settings locked things down at the instance level and so did CPU and I/O affinity. There really wasn’t much that you could do to specific users or groups. Sure, there was the query governor but all you can really do is set an “execution time threshold” for queries. I.E. If the estimated cost of a query exceeds the threshold, it won’t be allowed to run. Not bad for preventing very heavy queries from running but not really controlling resources either and the side effect is users might start opening support tickets thinking something’s wrong with the system because they can’t run their reports. Also, if your statistics are out of date and not automatically updated, queries may be incorrectly allowed or disallowed to run.

With Resource Governor, Admins can now set controls on how resources are consumed in SQL Server. At this time, the RG can control CPU and memory. Disk I/O and network I/O are not covered in this release. Still, this is already a giant step forward.

Let’s try a few things. First, the old way using the Query Governor cost limit. You can set this at the server instance (sp_configure) or on a per connection basis (set query_governor_cost_limit). If your goal is really to prevent long running queries during peak hours, you probably set this at the instance level. After all, how many users do you know will voluntarily not run their heavy queries? ;-) If you’re wondering what self-respecting DBA would allow reporting, DSS and other BI type queries run against a production OLTP system during business hours, well, DBAs don’t write the checks or run the business. It is reality today that the business users want/need to analyze data rapidly, not after a day, week or month. While you can create separate reporting servers, there are some genuine needs where a reporting server’s latency is beyond what the business users require. It’s the new world my fellow traditional DBAs - embrace and control it!

Now, let’s try this example. The following script (written by my colleague Suresh) scans the order tables in the Sales schema in the Adventureworks database and offers a discount for purchase quantities greater than 3. A cursor is used to scroll through and evaluate each row, taking action where appropriate. This query takes anywhere from 20-25 minutes to run on a workstation consuming a notable amount of CPU and memory.

USE AdventureWorks;
GO

DECLARE @l_SalesOrderID INT
SET NOCOUNT ON
DECLARE update_cursor SCROLL CURSOR
FOR
 SELECT SalesOrderID FROM Sales.SalesOrderHeader

OPEN update_cursor

FETCH NEXT FROM update_cursor INTO @l_SalesOrderID

WHILE (@@fetch_status = 0)
 BEGIN
  UPDATE Sales.SalesOrderDetail
  SET UnitPriceDiscount = 0.01
  WHERE SalesOrderID = @l_SalesOrderID
  AND OrderQty >= 3
  FETCH NEXT FROM update_cursor INTO @l_SalesOrderID
 END

CLOSE update_cursor
DEALLOCATE update_cursor
SET NOCOUNT OFF
GO

SQL Server 2005 (and earlier)
With SQL Server 2005 and earlier, you would do one of the following:

Instance wide: sp_configure ‘query governor cost limit’, 300

Per connection: SET QUERY_GOVERNOR_COST_LIMIT 300

Either of these will evaluate queries and disallow execution if they exceed 300 seconds. If you tried to execute the sample query from above, you will get a message that looks like:

Error 8649, Severity 17, State 1, Procedure iduSalesOrderDetail, Line 33
The query has been canceled because the estimated cost of this query (1157) exceeds the configured threshold of 300. Contact the system administrator.
Msg 3609, Level 16, State 1, Line 14
The transaction ended in the trigger. The batch has been aborted.

So that accomplishes your goal of not letting heavy queries execute. These settings can be changed at any time so you can setup SQL Agent to set the appropriate value at different times of the day. However, the big downside here is that your “heavy” queries do not get executed at all. This probably won’t go down very well with your end users. How about letting the query run but not allowing it to dominate server resources?

With SQL Server 2008, you have MUCH better control and can keep both regular OLTP and batch/reporting users happy.

There are a few terms we need to be familiar with before diving into Resource Governor. The following are brief descriptions of key terms. BOL has the gory details which I encourage you to check out.

  • Workload group: a logical way to classify different types of workloads you want to govern
  • Internal group: a “special” group created by and for SQL Server for system processes. This is not user configurable.
  • Default group: another special group created by SQL Server to be the catch-all bucket for any workload that doesn’t get allocated into a user defined group for whatever reason.
  • Classification function: a UDF that determines with group a submitted workload belongs to
  • Resource pools: a logical container for the amount of CPU and memory that members of the pool can consume
  • Internal pool: a “special” resource pool created by and for SQL Server to be consumed by system processes (in the internal group). This is not user configurable and will always have higher priority than all other pools.
  • Default pool: another special resource pool created by SQL Server to be the catch-all bucket for any group (stars with the default group) that doesn’t get allocated into other user defined pools. While it cannot be dropped, its configuration can be altered.

Getting started with Resource Governor.
Before we can start bossing workloads around with RG, there are a few things we need to consider.

Rules and environment prep:

  1. How many logical workgroups do you have in your database? E.g. Regular OLTP users, reports users, batch processors, administrators, security team, etc…. Can you standardize across your organization?
  2. What is the typical CPU and RAM utilization of your server? While limits can be adjusted easily, knowing the typical utilization will help avoid setting initial limits that are too low and causing performance problems.
  3. Is there a order of priority among your users?
  4. Is there an SLA (implicit or written) on query response time?

Once you figure out what you need from a user and administration perspective, you can then start implementing the controls.

Basic setup:

  1. Create workload groups in your environment that you want to have specific resource allocations for (others will fall into the default group)
  2. Create a classification function to place workloads in appropriate groups
  3. Register the classification function with Resource Governor
  4. Enable Resource Governor

The syntax itself is easy enough so I won’t elaborate here. The example below uses explicit transactions but it does not have to be that way. However, this is a recommended practice;  in case you make a mistake, it is easily undone (rolled back).

First, let’s create the buckets (known as groups) that we want to place our users into:

BEGIN TRAN
CREATE WORKLOAD GROUP ResGroupAdhoc
CREATE WORKLOAD GROUP ResGroupReport
CREATE WORKLOAD GROUP ResGroupAdmin
CREATE WORKLOAD GROUP ResGroupExecs

Next we need to create a classification function. This is the “filter” that decides which group each query submitted to SQL Server belongs to. Note that any workload that does not get classified by your function goes into the ‘DEFAULT’ group

CREATE FUNCTION ClassifierFn_Basic() RETURNS SYSNAME WITH SCHEMABINDING AS
 BEGIN
   DECLARE @ResGroup AS SYSNAME
   IF (SUSER_NAME() = ’sa’) OR (SUSER_NAME() = ‘REDMOND\v-jyong’)
      SET @ResGroup = ‘ResGroupAdmin’
   IF (SUSER_NAME() = ‘BillG’) OR (SUSER_NAME() = ‘CORP\DaBoss’)
      SET @ResGroup =  ‘ResGroupExecs’
   IF (APP_NAME() LIKE ‘%Management Studio%’) OR (APP_NAME() LIKE ‘%SQL Query Analyzer%’) OR
   (APP_NAME() LIKE ‘SQLCMD’)
      SET @ResGroup = ‘ResGroupAdhoc’
   IF (APP_NAME() LIKE ‘%REPORT SERVER%’) OR (APP_NAME() LIKE ‘%Microsoft Office%’)
      SET @ResGroup = ‘ResGroupReport’
   RETURN @ResGroup
END

COMMIT TRAN
GO

If you aren’t sure what App_Name to filter with, run Profiler for a while just to capture the ApplicationName column.

You can set classification conditions by a number of different connection properties including user name (both SQL Server and domain users), application name, hostname (source machine name), server role, etc… Check out BOL for details.

This function is just a sample of what you can do to place each user connection or application into specific groups. This is how you classify/categorize your users and it is with these groups that you will set resource utilization controls on later.

Next, we need to register the function with Resource Governor and enable RG.

ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION=dbo.ClassifierFn_Basic)
GO

Now that we have the function registered and RG enabled, we can set resource usage allocations for each group that we created.

First thing we want to do is to limit the amount of CPU resources ad hoc queries can consume. Let’s say we do not want ad hoc queries to consume more than 20% of CPU cycles  and no more than 15% of available memory if there are other workloads running. To do this, we need to create a resource pool, place the ad hoc group in that resource pool and set limits on that pool.

CREATE RESOURCE POOL ResPoolAdhoc WITH (MAX_CPU_PERCENT = 20,
     MAX_MEMORY_PERCENT = 15)

Next, we will assign the Adhoc group to the resource pool we just created so it will be governed by the policies we set for that pool. We then need to notify Resource Governor (kinda like what we already do when making a change with sp_configure).

ALTER WORKLOAD GROUP ResGroupAdhoc USING ResPoolAdhoc
GO
ALTER RESOURCE GOVERNOR RECONFIGURE
GO

Now all queries that are submitted via SQL Server Management Studio, Query Analyzer or SQLCMD (from a command prompt) will not be allowed to consume more than 20% CPU time or 15% of available memory if there are other workloads running. If the server isn’t very busy, RG is smart enough to let the queries use free cycles. For more details on how it works, check out BOL.

You can now repeat this process for other groups to set the max and/or min values for each group by creating and assigning resource pools for the groups. Try it out by submitting the long running query at the start of this article but use different UserIDs that belong to different resource groups. Run several instances of them and you’ll see the effect of the Resource Governor. It becomes very obvious when you run a lot of instances of that query.

Note that if you forget to assign a particular group to a resource pool, it will remain in the default pool. New applications or applications that are not defined in your function will fall in the default group which also falls into the default pool. (For example: another team may decide to use Toad as their query tool instead of Query Analyzer). That’s why it is always a good idea to set the default pool limits to values that you are comfortable with so that queries that are not caught by your classifier function will not hog server resources.

A few other things you should probably be aware of:

  • Dedicated Admin Connection runs in the “internal group”. That means you do not need to place it in a group to ensure it will always be able to run. SQL Server already takes care of that for you.
  • Don’t create vastly complicated classifier functions. All connections will be filtered through the function so if you have some convoluted code that performs 27000 checks, the connection may timeout before getting clasffied.
  • Multiple groups can belong to the same pool (e.g. default pool) but you can still impose some priority for allocation within that pool using the “IMPORTANCE” setting (LOW, MED, HIGH).
  • You can do all this in Management Studio, it doesn’t have to be via TSQL

Ok, so this is quite a bit more involved than the Query Governor Cost Limit in SQL Server 2005 and earlier but it also provides a lot more control and flexibility. This is one of those features that requires some work to take advantage of but it really isn’t much work plus the returns are huge. We covered the basics here which should enough to get you started. There are quite a few more things you can do with RG including setting up filters that just log events when queries run for a specific period (want an easy way to track offenders with long running queries?). BOL documents this pretty well and look for whitepapers (to come) on www.microsoft.com/sql/

So what should you do after upgrading to 2008 if you currently use Query Governor Cost Limit? I suggest creating the appropriate rules in Resource Governor (sorry, no such thing as an upgrade/migrate for this) starting with a close to 1-1 match for what you had before. Get used to its behavior then expand with more rules. This will work for probably >95% of the users of the Query Governor Cost Limit. There are some scenarios where you truly do not want a query to run if it is expected to last longer than x minutes. In which case, you can keep both; they are compatible.

Btw, if you’re wondering about how to monitor activity and how the allocations are actually being used, monitoring data is exposed via System Monitor (aka perfmon) and DMVs. BOL documents these well or you could just do what most DBAs do; fire it up and look around.

Beyond workload governance
Performance management and runaway queries aren’t the only things the Resource Governor is good for. With the ability to set resource utilization limits within a database, it becomes harder for malicious acts against your database such as a DDOS attack to cause widespread problems. It also provides greater flexibility and resource usage efficiency in database consolidation. There’s a good reason why this one feature is cited across multiple scenarios in the 2008 release. It really is super handy. Now as soon as we get network and disk IO added to the resources we can govern, DBAs will rule the world (more than before). :-)

joe yong