Notes on SQL

Random articles from a puzzled DBA

For several years I have happily relied on @@IDENTITY to return the latest identity of a row when inserting data. However, I have started using the OUTPUT clause and have discovered the entertainment to be had in getting the latest identity when writing to two or more tables with what can appear to be one …

Continue reading

Recently I have had to extract user’s details from Active Directory (AD) for certain security groups. Having looked through a slew of internet resources it is obvious that the work required to do this has changed little over many years – and it looks like is was deliberately designed to make it difficult. I’d like …

Continue reading

A heap is a table that has no clustered index – it may have non-clustered indexes but without a clustered index it is a heap. When a row is updated within the heap, if the new data size means a row cannot be stored in the original location, SQL Server moves the row to another …

Continue reading