AUSSUG Upcoming Sessions
In case you aren’t in the Australian SQL Server User Group, AUSSUG, there are a few upcoming sessions in Sydney which will be pretty useful – check out the official site to register. Sessions are free and always useful.
Lunchtime Wed 3rd March, 2010 – Ensuring Optimal Performance in SQL Server 2008 Based Applications with Viktor Isakov
Evening * Thu * 4th Mar 2010 – What’s new in Reporting Services 2008 R2 and PerformancePoint Services 2010 with Peter Myers, presenting what’s new in the upcoming release of Reporting Services 2008 R2 and PerformancePoint Services 2010
And TBA date in April 2010 – Knights of the SSIS Round Table – Kevin Wong, Glyn Llewelyn and myself will be presenting a series of mini demos followed by Q&A, so a chance to pick some expert brains
Hope to catch you at one of the sessions!
SQL Server 2008 Auditing
I recently got presented with this challenge: How do you monitor people disabling your SQL Agent Jobs? Not prevent, warn or notify… just be able to monitor and find out who did what, when?
Enter SQL Server Auditing, introduced in 2008.
What is SQL 2008 Auditing?
Well, you could read the official documentation on MSDN, but it’s a little overwhelming, so here’s the view from 500 ft. SQL Server Audit provides a secure means of tracking access and changes made to the database schema or its data. What this means is you can trace who tried to access what and when. If any command was issued to change the data, you can track this as well. You cannot track the changes made to the data. So for example if someone made an insert into a table, you could track that someone made an insert, who did it, when that insert was made and what the SQL of the insert statement looked like – except for what data was inserted. That task falls to Change Data capture (CDC) which isn’t directly tied to Auditing (currently).
How do I implement Auditing?
A SQL Server Audit is made up of two components, the first of which is the SQL Server Audit. This is a server level object (created in the master database) that defines where logs will be written. Logs can be written to either a file, the Application Log or Security Log. These must be created before you create any actual Audits.
The second component is either a Server Audit or Database Audit. Server Audits again exist at the server level, and track activities that occur at the server level, such as login attempts or permission changes. Database Audits exist within an individual database and track activities at a database level such as schema changes or data operations.
You can have multiple SQL Server Audits defining multiple log target locations. Multiple Server and Database audits can be created to use a given SQL Server Audit. This probably makes more sense when explained in pictures:
So how do I audit my SQL Agent Jobs?
Setting up Audits can either be done through SQL Server Management Studio (SSMS) or through SQL scripts. As usual any action carried out through the Wizard, so I will do the wizard first, then show the generated scripts.
Step 1 is setting up the SQL Server Audit. To create this in SSMS, under the Security Node of the Server is a folder called “Audits”. To create a new Audit, simply right click on the folder and choose “New Audit..”, as set out below:

Fig 2: Creating a SQL Server Audit
Then in the Wizard just enter the Audit name and in the dropdown select “Application Log”, as shown below. The alternatives are to the Security Log or to a File, but I won’t be covering those in this simple example. Click on OK and you’re done.

Fig 3: Creating a SQL Server Audit
The equivalent SQL script is below:
USE [master]
GO
CREATE SERVER AUDIT [My Sample Audit]
TO APPLICATION_LOG
WITH
( QUEUE_DELAY = 1000
,ON_FAILURE = CONTINUE
)GO
Now you have somewhere to write your log. Note that by default SQL Server Audits are disabled when they are created, which means nothing will be written to your log until until it is enabled. This can be done just by right clicking on it in SSMS and choosing “Enable”.
The next bit is to set up the Database Audit on the SQL Agent Jobs table, which is in the system table [msdb].[dbo].[sysjobs]. Under the msdb database, open up the “Security” folder and within there is the “Database Audit Specifications” folder. Right click here and choose “New Database Audit Specification…” as shown below.

Fig 4: Creating a Database Audit Specification
This will open the Create Database Audit Specification dialog. Because we are operating on msdb, unless you are logged in as sa, you probably won’t be able to create objects and the process will fail. So ensure the user you are logged in as has appropriate permissions on msdb. Because I’m playing on a Dev environment, I just allowed my own user access to msdb and gave them db_owner rights – this probably won’t fly in a production environment, of course!
The dialog is shown below. First task is to choose which SQL Server Audit to write to – so we use the one we created above called ”My Sample Audit”. You choose the Audit Action Type – i.e. what you want to log. In our case we want to see when changes are made to our jobs in SQL Agent, so we choose the “UPDATE” Action Type. Next we have the Object Class, which for this case is a Database Object, so “Object” is selected, and then the Object Name. Finally the Principal defines who is Audited – in the example I have selected “public” because every user is in the public role, so I will capture any users UPDATE commands issued on my selected table.

Fig 5: Creating a Database Audit Specification
Now here we hit a minor hiccup – you will note in the example above I have selected the object sysdtslog90 – it’s the only non-system view in the database, and the only one I can get to come up in the browser. The solution here is just to hit the “Script” button, and modify the generated code to point at the right table, as shown below:
USE[msdb]
GO
CREATE DATABASE AUDIT SPECIFICATION [SQL Agent Audit]
FOR SERVER AUDIT [My Sample Audit]
ADD (UPDATE ON OBJECT::[dbo].[sysjobs] BY [public])GO
This code runs just fine, and as you will see has the desired effect. As with SQL Server Audits, Database Audit Specifications are created in a disabled state. As before, just right click to enable and the Auditing will begin.
Finally to test, just change the Enabled state of any SQL Agent job on your server, then check the Application Log, where you will find an Event detailing who just changed its status!
Count the number of rows in every Table in a Database in no time!
Here is a piece of T-SQL code that uses DMV’s (Dynamic Management Views) to give an approximate row count of every table in your database in virtually no time at all. Bear in mind it is running off collected statistics so won’t always be 100% accurate – but it’s far quicker than doing a Count(*) on a table by table basis when you just need a rough idea when doing sizing. In case you don’t know what DMV’s there are, go poke around in SSMS – [Database] > Views > System Views and see what’s there. Anyway, the code:
SELECT s.[Name] as [Schema] , t.[name] as [Table] , SUM(p.rows) as [RowCount] FROM sys.schemas s LEFT JOIN sys.tables t ON s.schema_id = t.schema_id LEFT JOIN sys.partitions p ON t.object_id = p.object_id LEFT JOIN sys.allocation_units a ON p.partition_id = a.container_id WHERE p.index_id in(0,1) -- 0 heap table , 1 table with clustered index AND p.rows is not null AND a.type = 1 -- row-data only , not LOB GROUP BY s.[Name], t.[name] ORDER BY 1,2
For a very swift explanation – sys.schemas and sys.tables list the schemas and tables in the database, so joining these together on schema_id gives a list of all tables by schema in the database. Adding on sys.partitions then pulls in the partitions associated with each table, and finally sys.allocation_units pulls in the allocation units, which i’m not quite sure what they are – the guts of this query were pulled from another blog which I embarrasingly can’t trace back to now.
I’m no expert on DMV’s so if you have any views on the quality of this query – please leave a comment with your thoughts.
Microsoft Master Data Mangement Release announced
Microsoft’s Master Data Management tool, previously codenamed ‘Bulldog’ and slated to be included in the Office 14 release is now set to be included with Kilimanjaro – which seems to now be officially called SQL Server 2008 R2.
More details can be found at the SQL 2008 Official site. The rumour mill seems to imply that SQL 2008 R2 will drop at roughy the same time as Windows 7.
Just in case you have no idea what Master Data Management entails, it covers managing and centralising metadata within an organisation that may span many systems. The most common example is central management of customer records. For more insight and a more detailed explanation, I suggest you read this white paper on the subject by Roger Wolter and Kirk Haselden.
Kilimanjaro, Projects Gemini and Madison Webcast
For those who haven’t seen much of Project Gemini but have heard the buzz, this TechNet Webcast: An Early look at SQL Server ‘Kilimanjaro’ and project ‘Madison’ – will give you a good insight. It also has some features on reusable Reporting Services components which look very impressive and info on Project Madison, which provides scalability features. Registration as usual is a pain, and forget trying to use the site using any browser other than IE – I wish Microsoft would make their content easier to access.
Anyway, onto the webcast – about the 1st quarter of the webcast is the usual generic roadmap blurb, but then the presenter gets into the real meat of Gemini – an Excel based ‘in memory’ analysis tool that allows joining between entities without having to know about such things, superfast analytics – pivoting, calculation, charts etc. and then being able to publish to Sharepoint. From an OLAP analysis point of view, the Pivot Tables also has slicers (effctively table wide filters) displayed in the spreadsheet as well, and it would be good if that made it into Pivot Tables generally in the next release of Office. It looks like an incredible tool and very easy to use – and may be a powerful step towards the realisation of the ‘BI for the masses’ vision. The presenter did let slip one weakness though – much has been made of the 100 million rows of data demo – but that data still has to be loaded into memory first and will still take significant time. I also suspect that how successful Gemini will be is going to depend on how much it will rely on good data structures being in place in an organisation to support it. The Data Warehouse is going to remain the core part of any succesful BI delivery.
The next component of interest was the reusable Reporting Services components – there is the concept of a library of components that can be built – e.g. standard charts, logos, gauges etc – and then dropped into any report, either by a developer or a user in Report Builder 2.0. What really grabbed my attention is that these components are version aware – i.e. if the library version of the component is updated then if you reopen the report in design mode it will let you know and give you the option to update. Again this points to ‘BI for the masses’ as you can have developers create some great components which any user can then drop in to their home grown reports. Plus as any developer knows, there’s a lot of repetition and any options for code re-use are always appreciated.
Finally, Project Madison was covered – and seems more about scalability up to multi-terabyte warehouses. It was a bit infrastructure focused for me so most of it passed me by, but clearly Microsoft are stepping up to try and address the market perception that they can’t scale.
Anyway, this all will be dropped in late 2010 as Kilimanjaro – an interim release of SQL Server.
SSWUG Virtual Conference & New blog links
I have picked up from the SSIS Team blog the upcoming SQL Server World User Group (SSWUG) Virtual Conference from April 22-24. The Virtual Conference will all be scheduled in American time, so unless you happen to be active between 11pm and 7am .au time, you won’t be able to watch the presentations live. However the presentations are all viewable for up to 2 weeks after the events. Attendance costs 125 US$, or about 175 AU$. There are some compelling presentations from well known industry figures on both SQL Server, and of interest to the BI Monkey, SQL Server BI. Full details for each can be found here for BI and here for SQL Server.
I’ve also added links in the Relevant Blogs section for the SSIS Team Blog and for Jamie Thompson’s excellent SSIS Junkie, where I have found more solutions to SSIS problems that anywhere else on the net.
Installing SQL Server 2005, 2008 and PerformancePoint 2007 on Windows Server 2008
A bit of a mouthful of a title, but I have discovered in the process of trying to build some Virtual Machines to play on, that the above four pieces of software are not always friends.
A clean install of PerformancePoint Server 2007 (PPS) against SQL Server 2008 (SQL2K8) is not directly possible, even at PPS Service Pack 2 (SP2). There is an approach documented on TechNet which involves installing some SQL2K5 components (See scenario 3 of this article: http://technet.microsoft.com/en-us/library/cc514367.aspx) but I couldn’t get it to play ball. I would guess that PPS2007 won’t properly integrate with SQL2K8 for a while yet, so if you are installing PPS2007, do it against SQL2K5 SP2.
Next up, SQL2K5 won’t install cleanly on a vanilla install of Windows Server 2008 (Win2K8). You need to enable the Web Server Role, and then enable features as described in this KnowledgeBase article (http://support.microsoft.com/kb/938245/) – it’s not complicated. It also throws up a warning to patch SQL2K5 to SP2 when running the installer, but I would advise you did that on any install anyway.
Installations are never easy!
SQL Server 2005 SP3 Released 15 Dec 2008
I’ve just spotted SQL Server 2005 SP3 was released just before Xmas. It doesn’t appear to be a major pack (like SP2) so I would only advise installing SP3 on fresh installs. Upgrading will only be critical if the service pack addresses a specific issue on existing servers. Any 2005 server not on SP2 should be upgraded at least to SP2, as i’ve noted before.
Full details here: http://msdn.microsoft.com/en-us/library/dd353312(SQL.90).aspx
Upgrade to SQL2005 SP2, you fools!
Hitting one of these 3 messages in SSIS on SQL2005?
- The task is configured to pre-compile the script, but binary code is not found
- The script component is configured to pre-compile the script, but binary code is not found
- The task cannot execute in 64-bit environment because the script is not pre-compiled
Hotfixes are available here for Build 1399 and here for Build 1500
All the above can be fixed by applying SP2. And really, if you haven’t put SP2 on your SQL2005 you had better have a good reason for it, as there’s lots of other little things which will catch you out on your BI projects if you don’t. It was released in March 2007 so it’s not exactly a new patch either.
SQL 2008 New features
Time to take a break from BI based ramblings, and more importantly for my sanity, get the hell away from Cognos Data Mangler for a bit.
Recently I attended a SQL2008 skills update session to find out what’s new in SQL Server 2008. The answer is – from a manageability point of view – quite a lot. From a BI point of view, there’s two real stand out features.
First is the addition of the MERGE statement. This will be old hat to Oracle* users, but it allows you to do all your insert / updates in a single SQL statement as opposed to on a row by row basis. This delivers major performance advantages and will speed any ETL that delivers both new and changed rows to a table (in Oracle I managed to get a 20-fold improvement over row by row update / inserts). The only downside is this hasn’t been catered for in SSIS, so there’s scope out there for a custom component to take advantage of this.
Second is Change Data Capture (CDC). This captures in a mirror table – with metadata – any rows that are added or changed in a table on which CDC is enabled. Probably less relevant these days as most well designed databases will have update timestamps or versions, but a useful way of tracking changes in data – which ETL processes can then pick up on.
Otherwise there’s not much in SSIS, a new Office 2007 style interface for Reports, and things in SSAS which I don’t have a full handle on yet, but nothing groundbreaking. They have plugged some performance holes, but 2008 looks to be the administartion release, as 2005 was the BI release of the platform. Microsoft want to go head to head with Oracle, and assuming they can shake the perception that SQL Server isn’t scalable (which is is) then Oracle should start worrying. Because it’s usable and doesn’t require an expensive DBA and huge costs per feature.
As an aside, for geekery, the new spatial data type is incredibly cool…
