SQL Server Notes

Friday, 17 February 2012

User defined functions in Select statements

›
A UDF called in a SELECT statement, gets called once for each row returned, meaning the recordset is somewhat like a cursor in terms of perf...

Quorum doesn't move with group on Cluster (2008R2)

›
Having manually moved the SQL Resource group to another node on a Server2008R2 cluster, it was noticed that the Quorum was still on the orig...
Friday, 19 August 2011

Current CPU Usage

›
You may need to programmatically collect the current CPU Utilization. Why, is beyond me but whatever. The following script cannot be a funct...
Thursday, 17 June 2010

Unattended Installation

›
It takes a fair while to install SQL Server 2008 using the GUI. Clicking next through screen after screen, waiting for each form to validate...
Tuesday, 20 April 2010

Centralized Management Servers

›
This is pretty much an interim post until I get around to writing up a more detailed article, and forget half the set up details along the w...
Monday, 19 April 2010

Promote ALL Mirrors After a Single Fail-Over

›
Whilst on the subject of making jobs mirror aware. Often a single database (or even application) is logically split into multiple databases ...
Friday, 26 March 2010

Mirroring - After an Automatic Failover

›
So get this, our principal database failed in our mirrored pair. Thats cool, it automatically failed over. What isnt so cool is that the job...
Tuesday, 23 February 2010

Trailing blanks

›
Following on from my post on 29th December 2008 on the LEN() function gotcha: When comparing string values for equality, trailing blanks are...
Thursday, 12 November 2009

Backing up the Log Tail

›
Its possible with a recovered database, to make it so that it will start accepting log restores again. Getting the LSN's accurate is a b...
Tuesday, 10 November 2009

Assigning variables from multiple records in a table

›
It may be required to assign values to multiple variables from multiple rows in a table. Consider the following table: configName configValu...
Friday, 6 November 2009

No TRUNCATE_ONLY?

›
So, it looks like Microsoft removed the very useful 'truncate_only' option from the backup command. Citing that you should switch to...
Tuesday, 1 September 2009

Which FileGroup?

›
I need to free up space quickly on a certain drive, to do so means deleting some data and then shrinking that file group. So I need to be ab...

Determine Space Available in FileGroups

›
Sometimes its useful to know the space usage of individual database files. The following script uses the FILEPROPERTY function to display th...
Thursday, 20 August 2009

EXECUTE AS

›
If you want to test how something works for the little people (i.e. Those without system admin permissions on SQL), SQL 2005 introduced the ...
Tuesday, 18 August 2009

Upgrading to SQL Server

›
Upgrading and existing SQL Server instance to 2008 can be problematic if you have a large MSDB database. If you log ship any databases, or t...
Wednesday, 29 July 2009

Importing Files to Variables

›
There is functionality with SQLServer 2005 to import files directly from disk into variables or tables. This can be particularly useful for ...
Tuesday, 28 July 2009

EXCEPT & INTERCEPT

›
A couple of handy new operators are available in SQL versions from 2005 onwards, these are EXCEPT and INTERCEPT. Whilst not offering any new...
Thursday, 28 May 2009

Fragmention in SQL Server 2008

›
Here's a cool script I came accross - similar to SHOWCONTIG, but without being all invasive and locking your tables select * into dba..c...
Tuesday, 19 May 2009

Enforcing uniqueness on a combination of columns in different tables

›
Given the above schema, I had the need to create some kind of constraint that would prevent a particular gameTypeId being linked to more tha...
Monday, 29 December 2008

LEN() function gotcha

›
When using the LEN() function, be aware that before calculating the length of the passed string, SQL seems to perform an RTRIM() on the stri...
Thursday, 4 December 2008

Determine Which Log To Restore

›
If your logshipping fails, you can usually fix it with a full database restore or even a differential, though if your database is a couple o...

Log Shipping

›
Previously, I posted describing a query that can be used to determine the filename, datetime and LSN information for the last or any applied...

Deleting From Computed Columns

›
You may have noticed that deleting from a table with a computed column works fine in Query Analyzer, yet when its a scheduled job it fails. ...
Tuesday, 2 December 2008

Set SQL Agent Job Logs

›
You can use the following script to alter the output/log path for each step in every job scheduled in SQL Server Agent. It sets the filename...

Changing Ownership of SQL Agent Jobs & Schedules

›
If jobs or schedules are owned by a user account and that account is deleted, the job or schedule will fail to run. When creating a new job ...
Thursday, 30 October 2008

Service Control

›
You can use an extended stored procedure to manage the services that are running locally to your instance, this applies to SQL Server 2000 a...
Tuesday, 21 October 2008

Bit Masks

›
Rather than storing a bunch of settings as Bit fields, and COALESCING them or manually checking their value using a BIT MASK will allow you ...
Thursday, 16 October 2008

DBCC ShrinkFile() & Logical Fragmentation

›
Ahhh, this is frightening shit. What I'm doing is setting up a database with extra data so that I can simulate dropping a table and subs...
Thursday, 25 September 2008

Getting More From A Deadlock

›
Whilst on the subject of deadlocks, here is a cool way to capture a deadlock, and extract more information from it, other than a SPID and an...
Wednesday, 24 September 2008

Lock Contention

›
This mornings fiasco was interesting. For no obvious reason, the number of deadlocks on the server increased, soon it was every other statem...
Tuesday, 23 September 2008

Identifying a Failed Log Ship

›
In a previous post I demonstrated some SQL Server 2005 queries that would identify when a log shipping target was out of date, this post inc...

Open Transactions

›
If you have lots of database on a server, that are all used together, say in CROSS database queries, or perhaps they are bolted together via...
Thursday, 18 September 2008

Preventing Statements Outside Transactions

›
In some cases you may need to prevent statements or sub-stored-procedures from being executed either outside of a transaction or directly in...
Wednesday, 17 September 2008

Tracking Log Shipping

›
Here's a couple of queries, they only apply to SQL Server 2005+ that allow you to track what log was applied and when; and which was the...
›
Home
View web version
Powered by Blogger.