Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
The Voice of the DBA
 

Daily Coping Tip

Choose to smile today at something you encounter

I also have a thread at SQLServerCentral dealing with coping mechanisms and resources. Feel free to participate.

For many of you out there working in a new way, I'm including a thought of the day on how to cope in this challenging time from The Action for Happiness Coping Calendar. My items will be on my blog, feel free to share yours.

Executing Notebooks in a Stored Procedure

Jupyter Notebooks are a popular way of consolidating a number of code batches together and them executing them as separate batches or all together. These are essentially a document with notes and code, all of which are stored together. Databricks can run these, as can a number of other services. They are also integrated into various tools, like Azure Data Studio.

Just like many other technologies, we'd like to execute these in a way that suits our environment. While running these in a tool like ADS works fine, we might want to schedule these and check the results later. You can run notebooks with PowerShell, but keeping around results and managing the data is hard. Since many of us use SQL Server or Azure SQL Database, wouldn't it be great if we could find a way to have these run inside SQL Server and keep the results around?

I was poking around inside a database and discovered that I could do this. Only with notebooks that have T-SQL code, but that's usually what we'd want to do inside a SQL Server (or Azure SQL) database. I need to write a more detailed article on this, but there are a few basics that might help some of you understand how this works. Essentially, there is an undocumented extended stored procedure, xp_notebookparse, that will read the JSON internals of a notebook and allow you to extract out there T-SQL batches. The @execute = 1 parameter will cause each of these batches to be executed.

For results, a new notebook is created and added to a local temp file, #nbresults, as a BLOB value. You can explore the structure of this, but essentially, part of your stored procedure should take all the data from this table and add it to a permanent table in your database. If you use a stored procedure to wrap the extended stored procedure call and an INSERT..SELECT call together then you'll actually get nothing to happen because today is April first. It's April Fools and this is a joke. Hopefully, you aren't too disappointed.

Steve Jones - SSC Editor

Join the debate, and respond to today's editorial on the forums

 
 Featured Contents
SQLServerCentral Article

Power BI in Grafana

Steve Jones - SSC Editor from SQLServerCentral

An exciting new way of viewing your Power BI visuals. The functionality is a bit limited, but highly desired.

External Article

Exploring New SQL Prompt Features in SQL Toolbelt and SQL Toolbelt Essentials

Additional Articles from Redgate

Roseanna Whitelegg explores new SQL Prompt functionality that has been added to SQL Toolbelt and SQL Toolbelt Essentials to help teams increase their productivity, improve code quality, and make collaboration easier.

External Article

SQL Server and Oracle Create Table Comparison

Additional Articles from MSSQLTips.com

In this article we look at a comparison of different things you can specify when creating tables in SQL Server and in Oracle.

Blog Post

From the SQL Server Central Blogs - Starting LocalDB–#SQLNewBlogger

Steve Jones - SSC Editor from The Voice of the DBA

Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers. Lots of people have never worked with LocalDB,...

From the SQL Server Central Blogs - Power Automate – Returning the Last Day of the Month

Devin Knight from Devin Knight

Have you ever needed to set a property or field to the last day of the month? This is a common business problem that can

 

 Question of the Day

Today's question (by Steve Jones - SSC Editor):

 

Funny Quotes

What movie contains this quote? "On the other side of the screen, it all looks so easy. "

Think you know the answer? Click here, and find out if you are right.

 

 

 Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Using Collation in SQL Server

At what levels can we set collation in SQL Server 2019?

Answer: At the instance, database, column, and expression levels

Explanation: We can set collation at 4 levels: instance, database, column, and expression. Ref:

Discuss this question and answer on the forums

 

 

 

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.


SQL Server 2017 - Development
Remove some text - I would like to remove rtf from my Note column. I tried this: SELECT Note, LTRIM(Note, 'rtf') from [PatientNote]. I get an error. Please advise? I also tried the Replace function, but no text are altered/deleted.
OPENJSON - unnamed nested array - Currently working on sql script to extract from JSON file(s) but i've come across an unnamed array within a named array Wondering if anybody had any idea how to extract this? rest of my script is working fine using CROSS APPLY OPENJSON to extract what i require and where the arrays are named i'm having […]
Trigger: Need help to save activity log on delete - Hi, My table design as following, CREATE TABLE [dbo].[SFAProject]( [Id] [int] IDENTITY(1,1) NOT NULL, [TenderName] [varchar](200) NULL, [ClientsId] [int] NOT NULL, [SalesPersonId] [nvarchar](450) NULL, [SFAStageId] [int] NOT NULL, [SFATenderCategoryId] [int] NOT NULL, [SubmitDate] [date] NOT NULL, [TenderValue] [decimal](18, 2) NULL, [TenderCost] [decimal](18, 2) NULL, [TenderRemark] [varchar](500) NULL, [CrtBy] [nvarchar](450) NULL, [CrtDte] [datetime] NULL, [UpdBy] [nvarchar](450) […]
SQL Server 2016 - Administration
Slow SQL Server Performance PAGEIOLATCH_SH, CXPACKET help! - Hi All, (see attached waits) I have a very slow sql server, it seemed to happen over night and queries are still slow. index rebuild/reorg and statistics have been updated. what are my troubleshooting options?  
AG changed to Distributed state - Hi, AG Listener does not get connected application due to Availability Group name (primary) changed to Distributed state automatically and second node Availability Group name resolving state, also both the nodes databases not synchronized.  Please suggest what could be reason and why automatically AG state changed? Availability Group name - existing setting was Manual failover […]
SQL Server 2016 - Development and T-SQL
SQL Server Jobs - Retry Attempts - I know in SQL Server jobs, if a step fails, you can set the number of retries and interval.  What I want to do though is if a step fails, retry the entire job from Step 1, not just the individual step. The reason I need to do it this way, is that the first […]
Order of processing of windows function - Hi Experts, Please can you let me know the order of processing of the window functions, The second in order DENSE_RANK is executed first before the first one, is this right ? when I add group by to the below commands, there is no change whatsoever. May I know why group by has no impact […]
SQL 2012 - General
Scalability in SQL and NoSQL? - Hello All, I am working on a web application project and I want to know which database design is right from a scalability point of view between SQL and NoSQL. According to this source, SQL is vertically scalable (Add resources to increase the capacity of the existing hardware and software) and I have no idea […]
SQL Server 2019 - Development
Refactoring an Entity Attribute Value schema - Apologies in advance, as I know this has been discussed a million times already but I think our requirement is slightly different from the norm in that we have a well-defined, static set of attributes up front and our values are rows in a table. But feel free to ignore if you've had enough of […]
Amazon AWS and other cloud vendors
AWS S3 Questions - Hi all, Just starting out with AWS and had a few questions.. What are requests? And what constitutes a request? How can I figure out how many requests my backup product (Veeam, Rapid Recovery) will be making? Our backup products do not support directly backing up to glacier, and I'd like to save costs as […]
General Cloud Computing Questions
Few questions about cloud computing course - Hi I'm currently doing a networks management degree level 7. I'm in the final year of the level 7 and I'm the only one in the course who wants to go onto the level 8 add on cloud computing and infrastructure. 1: would the college still do the course if I was the only one […]
Azure Data Factory
ODBC Source into Data Flow Activity - I would like to work with an ODBC source in Azure Data Flow. However I understand that ODBC is currently not a supported Data Source. It was recommended on the Microsoft website that I move the data into into a supported data source and then use that in the Data Flow. Does anyone know of […]
Reporting Services
Dynamic Drop Down in SSRS - In SSRS reporting, is it possible to dynamically drive drop down values based on a main table and sub table?  (e.g. Category and SubCategory). For example, I have the following two tables: -- DROP TABLE #c CREATE TABLE #c (CategoryID int, CategoryDesc varchar(100)) INSERT INTO #c VALUES (1, 'Fruit') INSERT INTO #c VALUES (2, 'Veggie') […]
Create 1 calendar for each student - Hello! I'm attempting to replace a clunky mail merge process with SSRS 2016. The data is the attendance code for a list of students on each school day of a month. (picture Columns: Student_id,  School_Date, Attendance_Code for a given month) I need to depict their attendance on a calendar, simply placing the contents of Attendance_Code  […]
Integration Services
Split column on Data Types - Please assist? I would like to split column Event in two columns based on data types.
 

 

RSS FeedTwitter

This email has been sent to {email}. To be removed from this list, please click here. If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com. This newsletter was sent to you because you signed up at SQLServerCentral.com.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -