Jobs That Beat The Caring Out Of You

Professional Development
I was inspired by Jen McCown's story here. Read that first. It's WAY better than mine. This is not an April Fools post. Fools are involved, but none were harmed. Oprah-Level SA YOU GET SA! AND YOU GET SA! I'm working for a DOTCOM startup as a developer. I have SA privs. I have SA privs because EVERYONE has SA privs. We're developing a system (this was a long time ago) in SQL Server 6.5. The database originally was designed in Paradox (where I started my career). To be as kind as possible, the database design was a living nightmare, like the worst possible black, ichorous, Lovecraftian, tentacled monstrosity to walk the earth database. It was bad. On top of that, the code we were writing was always barely functional.…
Read More

Can You Force A Parallel Plan in Query Store?

SQL Server 2016, SQL Server 2017
I love the questions I get when presenting: Can You Force a Parallel Plan in Query Store. I haven't a clue. The trick I think is going to be in setting up the test. Let's try it out. Reliably Getting a Parallel Plan Because this is for testing, rather than try to build some crazy query that may or may not go parallel, I've decided to cheat. I'll take advantage of a little functionality that ensures I see a parallel plan when I want to. Here's my code: DBCC TRACEON(8649); GO SELECT soh.OrderDate, soh.ShipDate, sod.OrderQty FROM Sales.SalesOrderHeader AS soh JOIN Sales.SalesOrderDetail AS sod ON sod.SalesOrderID = soh.SalesOrderID WHERE soh.SalesOrderID = 43705; GO DBCC TRACEOFF(8649); Traceflag 8649 will force all plans to go parallel by effectively making the Cost Threshold for…
Read More

Monitoring Your Databases and Servers and…

Redgate Software
You absolutely need to know about the servers you have under management in your estate. You need to know about the databases. Uptime, performance, behaviors, errors, corruption and a much longer list of items that will frankly fill this blog post, are very important to you. I've been doing work in and around data and databases for over 30 years now (OMG, I'm so old). I feel like I know how monitoring works, what's important, what's not, what's vital and what's trivial. However, I know that you have different needs, different requirements, different problems. Those problems need different solutions. Tell Us The Problems You're Solving, and How Or not. I'm assuming that you're doing the work you need to do to solve these issues, but maybe you just don't know…
Read More

Compliance Ain’t Easy

Redgate Software
I'm sure by now you've heard of the GDPR and some of the large scale data breaches that have occurred within it. If you haven't heard of the GDPR, you've been under a rock, or, you're like me, a United States citizen (it's amazing how little we know about this oncoming train). If you're seeing the four letters GDPR strung together for the first time, then you better jump on learning about it right now. Why? Let's string together more letters, CPPA. That stands for the California Privacy and Protection Act. That's a law modeled off the GDPR that goes into effect in 2020 (yeah, nine months). Compliance Isn't Always Spelled GDPR Maybe you're not in an EU country and you don't have any person's data from there. Maybe you…
Read More

Database Development Gone Wrong

Redgate Software
I recently shared a story about how I was personally responsible for a development project going off the rails (and oh boy, did it go off the rails). It's a very painful story to share since I was the principal bad guy. However, I learned a lot of lessons from it. Now, it's your turn. Redgate Software (yes, my employer), is running a contest between now and March 20, 2019. We want to hear your story about database development gone wrong. It can be a horror story like mine, or just a simple story of the pain involved when developing databases ('cause there's always a little pain). Inspiration! What, the chance to $150 or more isn't inspiring? OK, how about this, here's Kendra Little's story about her database development... not…
Read More

Missing Indexes in the Query Store

SQL Server 2016, SQL Server 2017, T-SQL, Tools
I've shown before how to use the DMVs that read the plan cache as a way to connect the missing indexes suggestions with specific queries, but the other place to find missing index suggestions is the Query Store. Pulling from the Query Store The plans stored in the Query Store are exactly the same as the plans stored within the plan cache. This means that the XML is available and you can try to retrieve information from it directly, just as we did with the missing index queries against the DMVs. Here's the query modified for the Query Store: WITH XMLNAMESPACES (DEFAULT 'http://schemas.microsoft.com/sqlserver/2004/07/showplan') SELECT qsqt.query_sql_text, rts.plan_id, rts.NumExecutions, rts.MinDuration, rts.MaxDuration, rts.AvgDuration, rts.AvgReads, rts.AvgWrites, qsp.QueryPlan, qsp.QueryPlan.value(N'(//MissingIndex/@Table)[1]', 'NVARCHAR(256)') AS TableName, qsp.QueryPlan.value(N'(//MissingIndex/@Schema)[1]', 'NVARCHAR(256)') AS SchemaName, qsp.QueryPlan.value(N'(//MissingIndexGroup/@Impact)[1]', 'DECIMAL(6,4)') AS ProjectedImpact, ColumnGroup.value('./@Usage', 'NVARCHAR(256)') AS ColumnGroupUsage, ColumnGroupColumn.value('./@Name',…
Read More

system_health Extended Events in Azure SQL Database

Azure, SQL Server
The system_health Extended Events session is incredibly useful. Further, it's running, by default, in every server you have under management that is 2008 or greater. Things are not the same in Azure though. system_health in Azure SQL Database If you look at the documentation for system_health, it shows that it's applicable to Azure SQL Database. However, if you try to run the example query, it won't work. This is because the implementation of Extended Events inside Azure SQL Database is a little different. Instead, you need to use the Azure SQL Database equivalent system views to create the same query like this: SELECT CAST(dxdst.target_data AS XML) FROM sys.dm_xe_database_session_targets AS dxdst JOIN sys.dm_xe_database_sessions AS dxds ON dxds.address = dxdst.event_session_address WHERE dxds.name = 'system_health'; Now, running this in Azure, prepare to be…
Read More

How Do You Export A Database in Azure Data Studio

SQL Server, SQL Server 2016, SQL Server 2017
I've been writing a bunch about Azure Data Studio. I've also been recording videos on the topic. A comment I received recently asked how to export a database from Azure Data Studio. It made me want to explore the topic of exporting a database as it relates to Azure Data Studio. Export? When we say export, what exactly do we mean. It could be as simple as exporting data to a flat file for consumption in Excel or something. It could be creating a backup. Maybe we mean creating a bacpac file. We could also be looking at creating individual scripts for objects within the database. Finally, what about a full export of the database object definitions? Any or all of these could be what the question was about. So,…
Read More

Installing Extensions to Azure Data Studio

Azure, SQL Server 2016, SQL Server 2017, T-SQL
If you're even thinking about experimenting with, let alone actively using, Azure Data Studio, you need to plan on installing a few extensions. Buck Woody has a great list that you should look through in this blog post. If you're just getting started with Azure Data Studio, I have an introduction here. Depending on the extension, this could be a simple as a mouse click. However, not all the extensions are that easy. Let's explore this just a little so when you do start using Azure Data Studio, things are easy. Extension From a Mouse Click For this bit of the blog post, we'll stick to nothing but mouse clicks, but, if you really want to bring the power within Azure Data Studio, you really need to learn keyboard shortcuts…
Read More

Query Store and a READ_ONLY Database

T-SQL, Tools
What happens in Query Store when the database itself is READ_ONLY? Yeah, I don't know. Let's find out. READ_ONLY The only way to find out how this works is to test it. So, let's write some code: CREATE DATABASE testquerystore; GO ALTER DATABASE testquerystore SET READ_ONLY; GO ALTER DATABASE testquerystore SET QUERY_STORE = ON; Executing that resulted in a small glitch in the Matrix: 8:00:54 AMStarted executing query at Line 1Commands completed successfully.8:00:54 AMStarted executing query at Line 2Commands completed successfully.8:00:54 AMStarted executing query at Line 5Msg 5004, Level 16, State 6, Line 5To use ALTER DATABASE, the database must be in a writable state in which a checkpoint can be executed.Msg 5069, Level 16, State 1, Line 5ALTER DATABASE statement failed.Total execution time: 00:00:01.448 Well that's not going to…
Read More