Thursday, 19 January 2017

SQL Shack: Using sp_server_diagnostics

Delighted to say that my first article on SQL Shack, the community website for Apex SQL, has been posted. Really cool; I am over the moon to be joining the team.

After having a few ideas in mind it was a tough choice of first post but went for sp_server_diagnostics a rather helpful stored procedure built into SQL. I've been putting it through its paces on a client site lately and it is really useful. Whilst it won't replace any of my usual methods like DMV scripts it's certainly a handy addition to the troubleshooting toolkit.

Here's the link:http://www.sqlshack.com/using-sp_server_diagnostics/

Tuesday, 17 January 2017

The Q&A Sessions for 2017

I've rejigged the blog a little bit for 2017 and added a dedicated page for the Q&A sessions. If you're wondering what they are, well its when I get to quiz fellow database professionals about various aspects of working with SQL Server. Great advice, great insights and getting to know some SQL pros a bit better!

You can view the sessions right here: http://sqlclarity.blogspot.co.uk/p/the-q-sessions.html

Wednesday, 11 January 2017

Blog posts I've been reading.

The greatest part of being a SQL professional is being part of a vibrant and buzzing community of like minded people and blogs are very much a important part of it.

I read blogs in different ways. There are several that I follow and make an effort to read regularly. Others I find when I am actively searching for information on a particular topic and then there are posts that I happen to come across via social media feeds.

I decided that a big part of my blog this year would be to share the posts that I have been reading so from time to time I will put up a post like this one with some links that I think you'll find useful. 

So top of the list and a very relevant post to start us off is Getting Started Blogging #SQLNewBlogger from Steve Jones (twitter). Steve is quite literally the voice of the DBA and I'm a huge, HUGE fan of his reads. This article contains some great advice on how to start your blogging and how to get your blog out there. Great advice and seriously encouraging too so well worth a read if you're starting out: https://voiceofthedba.com/2017/01/09/getting-started-blogging-sqlnewblogger/ 

Next up, Should you back up system databases on an Azure VM? Well should you? I'm not going to tell you, but Denny Cherry (twitter) from Denny Cherry & Associates Consulting will if you follow the link: http://www.dcac.co/syndication/should-i-back-up-system-databases-on-an-azure-vm

SQL Server Extended Event Handling via Powershell comes via Dave Mason (twitter). It's a post in what has come to be a fantastic little series on event handling and I thoroughly recommend checking the posts out: http://itsalljustelectrons.blogspot.co.uk/2017/01/SQL-Server-Extended-Event-Handling-Via-Powershell.html

Speaking of Powershell, if you're wondering how to setup Always Encrypted with it then the SQL Server Security Blog has it covered here: https://blogs.msdn.microsoft.com/sqlsecurity/2017/01/04/getting-started-with-always-encrypted-using-powershell/

Now some of these posts aren't red hot off the press; that's because this week (yesterday even) was T-SQL Tuesday hosted by none other than Brent Ozar (twitter). For those who don't know T-SQL Tuesday is the brainchild of Adam Machanic (twitter) and basically means that each month a blogger "hosts" the party and will put forward a blogging subject. Other bloggers will then write articles on said subject and the host will then round up the blogs so they can be read in one place. 

Here is this months subject: https://www.brentozar.com/archive/2017/01/announcing-t-sql-tuesday-87-sql-server-bugs-enhancement-requests/ and some info about T-SQL Tuesday too here. There are loads of posts to get stuck into and its always great to see such a variety of posts and ideas about one particular item.

So that is all for now, happy reading and if you want to suggest a post of your own or indeed anyone's for that matter then drop me a line and I will gladly feature it!!

Sunday, 8 January 2017

Data Platform Blogs - Top Posts of 2016

The SQL Server team kicked off 2017 with a recap of their most popular posts from 2016. Notable posts include the release of SQL Server 2016 and it's first service pack and of course so does Linux! 

All the posts mentioned are well worth a re-read (because I am sure you did first time round) and you can do so right here:

https://blogs.technet.microsoft.com/dataplatforminsider/2017/01/04/welcome-2017-recap-of-top-sql-server-posts-of-2016/

Friday, 30 December 2016

As one year ends another one starts...


My last post was my thoughts around SQL Server over the past 12 months and looking forward to 2017. This post, the last one of 2016, is about what I am planning to be doing next year and what direction I hope to be moving DTA towards.
Firstly there’s SQL Clarity, the humble little blog that hit well over 20k views this year. OK, that number might seem insignificant compared to some but for me it was a huge milestone; especially considering the amount of time I spent away from writing.
So what about 2017? Well the first thing to spring to mind is the monitoring script series to conclude. It’s at a nice halfway point at the moment with a couple of parts on wait statistics to publish very soon. Next year will see more series posts as I have a couple of topics that I really want to put out there as soon as I can! I’ll also be linking more to articles that I’ve been reading and really getting a wide range of content out there.
There will be the welcome return of the Q&A sessions. I had always hoped these would be much more of a regular feature, the feedback was always positive and there were certainly a lot of awesome people interested in doing them and once more, huge thanks to Kevin and Sergey for contributing!! If you are interested then keep a look out as I will be reaching out to the SQL community for volunteers very soon!
There is also an announcement which I am really excited about that I could be making as early as the beginning of January so keep your eyes peeled for that.
Then there is DTA; not to be confused with the tuning advisor by the way! For those that don’t know I entered the world of consulting this year finally fulfilling a long term ambition of mine. I’m delighted to have got to this point and if I had to thank everyone who has helped me on the way we would be here for a long time. Anyway, I hope you know who you are and how grateful I am.
DTA itself will start to build next year. There are a couple of areas that we will be focusing on to begin with but before anything else happens the online presence needs to be put into place so that will be happening very early on next year. It will be a very separate entity to the SQL Clarity blog; the latter will be much more from a personal perspective. Needless to say, there will be lots happening over the next couple of months as far as DTA is concerned.
As for technology, there is so much to be looking into its difficult to pin down a specific plan at the moment (I am after all reading three books in parallel!). Obviously SQL2016 comes with lots of bells and whistles to look into and get accustomed to using. vNext as well is something I will be spending lots of time with, the adaptive query processing features are a particular area I want to keep a keen eye on.
There's also R. I've spent a little bit of time using R this year and already I'm hooked. My personal opinion is that there will be another BI explosion next year so it makes sense to hone those skills in that area.
All in all it has been an amazing year and a big personal wish of mine is to be much more involved in the SQL community over the next year, whilst it might seem that I have enough on my plate I’m sure that isn’t the case, so I am looking forward to seeing what is in store on that front!
So all that is left is for me to say a huge thank to everyone. I really hope you all have happy and successful 2017’s!
All the very best,
David.
 
 
 
 

Thoughts on 2016 - 2017


2016 has been, as far as SQL Server is concerned, one of the best years that I can remember. The biggest point for sure is the release of the 2016 version which many people have classed as the biggest release since 2005, a view I wholeheartedly share.
Microsoft have added lots of new functionality, released some existing limitations and rather surprisingly made several features available to editions that don’t come with the hefty enterprise fee, In-Memory OLTP on Express Edition anyone?! I won’t dwell too much on the new functions; you can read about them here.
Then came the announcement that SQL Server will be available on Linux, a move heavily broadcast by Microsoft and bloggers alike. Personally, I haven’t tried it yet. I will get round to it and I am wondering if and when we’ll hear about Linux estates that are taking SQL Server on board because above all else, this is all about increasing SQL Servers user base.
One of the new features in 2016 that really interests me is the introduction of R Services for SQL Server. R is a rich and powerful analytical language used for data science activities such as data exploration and predictive modelling. The integration with SQL Server means that we can develop analytical solutions using very familiar tools but we can also scale our analysis to huge sets of data without performing any of the costly traditional movement of data - this is a very important factor on how we will approach data analytics.
On that note, it’s worth reading Microsoft’s vision for the data platform as this really is the way they’re heading. Traditional Business Intelligence platforms just don’t cut it anymore and must make way for technologies that can accommodate larger, broader sets of data as well as present much more immersive and interactive user experiences. The world of Business Intelligence (as an umbrella term), is going to have huge focus in 2017 with the likes of predictive analysis, AI and Machine Learning!
It goes without saying, but the cloud is a fundamental part in all of this. Whether you're thinking of using hosted SQL instances in Azure/AWS or utilising Power BI with Office 365 there are a wealth of options and features to look into. Cloud based solutions get an awful lot of publicity and whilst there are some clear advantages there is still very much a case for on-premise regardless of what anyone tries to tell you. For me, the new features coming into vNext demonstrate Microsoft's commitment to the on-premise versions.
So for administrators and developers alike it really is an exciting time to be working with SQL Server, I certainly can't recall a time where there has been so many different things happening at the same time and so many new learning opportunities (I haven't even mentioned PowerShell!), all in all 2017 promises to be a really interesting year.


I’ll definitely cover what my plans are for DTA (not to be confused with "the DTA") in another post but for now I would like to wish everyone a very happy new year and I hope you all have a hugely successful 2017 - whichever roads you are taking!

Friday, 16 December 2016

Identity Columns and Rollbacks


Identity columns are a very commonly used feature within tables in SQL Server. Basically when specified as an identity a column will automatically increment by the specified value; so if we have an identity increment of 1 and insert 5 rows they will automatically be numbered 1 to 5.
One cautionary measure with identities is that they don’t reset themselves when rows are deleted. If we delete rows 4 and 5 the next row will still be populated as identity 6. That’s fine, but what happens if we rollback an insert.
Here’s a quick table with three columns one of them ID which is set as an identity with an increment of one.
CREATE TABLE [dbo].[IdentityRollback](
       [ID] [smallint] IDENTITY(1,1) NOT NULL,
       [FirstName] [varchar](50) NULL,
       [LastName] [varchar](50) NULL,
) ON [PRIMARY]

GO

Very simple and straightforward, let’s insert a row with the following:
INSERT INTO IdentityRollback (FirstName, LastName) VALUES ('David','Alcock')
Note that I haven’t inserted a value for ID, let’s make sure all is well in there.

SELECT * FROM IdentityRollback 


As expected the one row and the ID column has started at our first increment. Now we’ll add the same row but rollback the transaction:
BEGIN TRAN
 INSERT INTO IdentityRollback (FirstName, LastName) VALUES ('David','Alcock')
 
ROLLBACK TRAN

We can run the select statement again to make sure no row has been inserted:
SELECT * FROM IdentityRollback

Exactly the same! Which is good because it shows the transaction has rolled back exactly as intended. So what happens when we insert a brand new row, what will the ID column be?

I’ve always wanted to meet Tom Hanks so let’s put him in the table.

INSERT INTO IdentityRollback (FirstName, LastName) VALUES ('Tom','Hanks')

The same select again,

SELECT * FROM IdentityRollback

but this time…




Although the transaction was rolled back, it hasn’t reset the identity. That’s actually happened by design; if there were other transactions creating rows (and identities) then imagine having to wait to see if every identity was successfully committed or not. If you need to rely on a sequential column of integers then perhaps the identity functionality isn't going to be the best option for you.

For further reading Pinal Dave has a solution to the problem here