It’s T-SQL Tuesday!!T-SQL Tuesday is the brainchild of Adam Machanic (Blog | Twitter). December 2009 was the first T-SQL Tuesday invitation that went out by Adam. It is a monthly blog party on the second Tuesday of each month. Currently, Steve Jones (Blog | Twitter) organises the event and maintains a website with all previous posts which you can find here. Everyone is welcome to participate in this monthly blog post.
My personal count
This is my seventh contribution to T-SQL Tuesday!
How do I use Notebooks?
I’ve had a play with them on and off but not really used them in anger, I’ve also not observed them in use anywhere I’ve been (so far). The invite has led me to do some research on Notebooks, it’s been quite interesting to learn a bit more and consider the possibilities. A big shout out to Rob Sewell, his blog has been a brilliant resource and some of the ideas he has presented have been really interesting, I highly recommend you checking it out.
What is a Notebook
Jupyter Notebook is an open-source web application, allowing you to create documents containing code, images, text and interestingly, execution results. You can author Notebooks using Azure Data Studio which is great, because it means I get to play with them directly on my Mac :)
The text cell provides rich text and markdown interfaces. You can toggle them using the switches on the far right. The first icon provides a rich text interface, the second provides rich text plus preview, the third icon provides a markdown interface.
I like using markdown - my site is powered by Hugo which also uses markdown so it is possible for me to copy content from my site into a Notebook if I were to create a supporting Notebook to a blog post lets say….or just to be able to reuse content easily. I’ve been using Azure DevOps Wikis quite a bit of late and that also uses markdown so it’s a useful language to become familiar with. There’s a great guide for markdown here.
Most markdown seems to be supported, though I haven’t had any luck using local image references. You can reference images like so;
The first command references a local image and won’t work, whereas the second command references a remote one. However, it is possible to paste images straight into a text cell using rich text! So from my Mac I can hit ⌘ + ctrl + shift + 3 (contorting my fingers!), draw a box around a portion of my screen and that will be clipped straight to clipboard which I can then paste straight into the Notebook!
Focusing on SQL, you can create a code cell and write code that can be executed directly within the Notebook. If you create multiple cells these can be run one at a time or all at once;
What is really interesting with this, is that the execution results are stored with the notebook! This provides some interesting opportunities.
How I might use them in the future
The ability to enrich code with images and annotations provides some interesting opportunities to build clear and concise operational documentation. This could be a set of steps in order to run through an entire process, or to take remedial steps following a load failure.
The ability to store results provides some interesting troubleshooting opportunities. For instance, a Notebook could be created to capture metrics in the event of an issue in order to assess them the following day, it also offers the ability to send remote users / clients a suite of queries to assist with troubleshooting, those queries could be run and then returned to you without being on site. Pretty cool!
Rob has done some cool stuff with automating Notebooks that I need to sit down and have a play with, I suggest you check it out too! I’ll be exploring this more in the coming months and appreciate Steve picking this as it’s been a worthwhile exploration.
I’ve edited this post to add…in wrapping this up I decided to push the Notebook I used to create some screenshots, to Github so I could share it in the post. What I was surprised to see was that Github does a very neat job of displaying the notebook to you, check it out!