-->
SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Bert Wagner

Bert Wagner is a Business Intelligence Developer at Progressive Insurance. He enjoys solving challenging data transformations with T-SQL and optimizing for query performance. In addition to BI development, Bert loves building ASP.NET MVC web apps and building Internet of Things projects.

Conditionally Returning Rows Based On Query Results

While I normally prefer formatting my query results in a downstream app/reporting layer, sometimes I can’t get around adding some business formatting logic to my SQL queries.

Today I want to show you four different ways to conditionally output rows of data based on a SQL query.

Setting Up The…

Read more

0 comments, 102 reads

Posted in Bert Wagner on 16 October 2018

The Project Graveyard

This post is a response to this month’s T-SQL Tuesday #107 prompt by Jeff Mlakar.  T-SQL Tuesday is a way for the SQL Server community to share ideas about different database and professional topics every month.

This month’s Halloween themed topic asks to “…
share a story about a… Read more

2 comments, 2,322 reads

Posted in Bert Wagner on 9 October 2018

Power BI Dashboards, Reports, and Datasets with the SQL Chefs

This week I had the opportunity to learn about dashboards, reports, and datasets in Power BI using the best kind of teaching tool: fresh, delicious, chocolate chip cookies.

Be our guest for the web’s premier Power BI food show as Eugene Meidinger (@SQLGene) explains how these concepts relate… Read more

0 comments, 2,550 reads

Posted in Bert Wagner on 2 October 2018

Shortchanged with International Money in SQL Server

Imagine you have to perform some salary analysis for your employer International Mega Corp.

The data you have to work with looks something like this:

DROP TABLE IF EXISTS ##InternationalMegaCorpSalaries;
GO
CREATE TABLE ##InternationalMegaCorpSalaries
(
	EmployeeId int IDENTITY,
	Salary nvarchar(10),
	Country nvarchar(20),
);
INSERT INTO ##InternationalMegaCorpSalaries VALUES ('1,000.00','United States');
INSERT…

Read more

1 comments, 1,509 reads

Posted in Bert Wagner on 25 September 2018

Extracting JSON Values Longer Than 4000 Characters

A while back I built an automated process that parses JSON strings into a relational format.

Up until recently this process had been working great: my output table had all of the data I was expecting, neatly parsed into the correct rows and columns.

Last week I noticed an error… Read more

6 comments, 106 reads

Posted in Bert Wagner on 18 September 2018

Faking Temporal Tables with Triggers

This post is a response to this month’s T-SQL Tuesday #106 prompt by Steve Jones.  T-SQL Tuesday is a way for the SQL Server community to share ideas about different database and professional topics every month.

This month’s topic asks to share our experiences with triggers in SQL Server. Read more

9 comments, 2,124 reads

Posted in Bert Wagner on 11 September 2018

Does The Order Of Index Columns Matter?

When beginning to learn SQL, at some point you learn that indexes can be created to help improve the performance of queries.

Creating your first few indexes can be intimidating though, particularly when trying to understand what order to put your key columns in.

Today we’ll look at how row… Read more

2 comments, 3,808 reads

Posted in Bert Wagner on 4 September 2018

Ignoring NULLs with FIRST_VALUE

Watch this week’s episode on YouTube.

The SQL Server FIRST_VALUE function makes it easy to return the “first value in an ordered set of values.”

The problem is that if that first value happens to be a NULL, there is no easy, built-in way to skip it.

While a… Read more

5 comments, 958 reads

Posted in Bert Wagner on 28 August 2018

FizzBuzz and Multiple Recursive Member CTEs

Watch this week’s episode on YouTube.

Last week I needed to write a recursive common table expression.  I’ve written them before, but it’s been a while and needed to visit the documentation to reference the syntax.

Instead of going straight to the examples, I decided to read into some… Read more

4 comments, 2,024 reads

Posted in Bert Wagner on 21 August 2018

6 Techniques For Troubleshooting Your Code

This post is a response to this month’s T-SQL Tuesday #105 prompt by Wayne Sheffield.  T-SQL Tuesday is a way for the SQL Server community to share ideas about different database and professional topics every month.

This month’s topic asks to share a time you ran into a metaphorical… Read more

5 comments, 3,525 reads

Posted in Bert Wagner on 14 August 2018

Displaying Long Values in SSMS

Click here to watch this week’s video on YouTube.

I write a lot of dynamic SQL and frequently encounter variables that contain many characters:

DECLARE @LongValue NVARCHAR(MAX) = CAST('' AS NVARCHAR(MAX)) + 
N'SELECT
	''A'' AS AShortValue,
	'''+REPLICATE(N'A',4000)+''' as ALongValue
ORDER BY 1';

This variable is 4059 characters long, and… Read more

2 comments, 150 reads

Posted in Bert Wagner on 7 August 2018

Should You Use Index Hints?

Watch this week’s post on YouTube

One of the things that the SQL Server query optimizer does is determine how to retrieve the data requested by your query.

Usually it does a pretty good job, which is a great because if it didn’t then we’d be spending most of our… Read more

3 comments, 2,782 reads

Posted in Bert Wagner on 31 July 2018

Pinal Dave Helps Me Fix My Performance Tuning Problems

Be sure to check out this week’s video on YouTube.

This week I was fortunate enough to film a video in collaboration with Pinal Dave, the SQL Authority himself.  Pinal is creative, hilarious, and kind; making this video with him was A BLAST!

Although the video is a little tongue… Read more

4 comments, 197 reads

Posted in Bert Wagner on 24 July 2018

T-SQL Tuesday #104 Roundup

This month’s T-SQL Tuesday topic asked “What code would you hate to live without?” Turns out you like using script and code to automate boring, repetitive, and error-prone tasks.

Thank you to everyone who participated; I was nervous that July holidays and summer vacations would stunt turnout, however we wound… Read more

5 comments, 2,456 reads

Posted in Bert Wagner on 17 July 2018

Building Dynamic Table-Driven Queries

This post is a response to this month’s T-SQL Tuesday #104 prompt by me! T-SQL Tuesday is a way for SQL Server bloggers to share ideas about different database and professional topics every month.

This month’s topic is asking what code would you hate to live without?


When given… Read more

1 comments, 2,820 reads

Posted in Bert Wagner on 10 July 2018

Code You Would Hate To Live Without (T-SQL Tuesday #104 Invitation)

The recent news about Microsoft acquiring GitHub has me thinking about how amazing it is for us to be part of today’s online code community.

Before modern online programming communities, finding good code samples or sharing your own code was challenging.  Forums and email lists (if searchable) were good, but… Read more

42 comments, 179 reads

Posted in Bert Wagner on 3 July 2018

Filtering Tables, Procedures, And Other Objects In SSMS

While the text of this post contains good information on SSMS object filters, I highly recommend watching this week’s video on YouTube – I stretched my creativity with filming this week while I was on vacation.

This week I’m sharing a trick I learned at Jess Pomfret‘s Ohio North… Read more

5 comments, 2,019 reads

Posted in Bert Wagner on 26 June 2018

Join Elimination: When SQL Server Removes Unnecessary Tables

In this post and video at SQLPerformance.com, I discuss what join elimination is and how it works in SQL Server.  Join elimination is one of the many techniques that the SQL Server query optimizer uses to create efficient query plans. Specifically, join elimination occurs when SQL Server can establish… Read more

0 comments, 453 reads

Posted in Bert Wagner on 19 June 2018

Prioritizing Index Performance Pains – What I Learned From Brent Ozar’s Master Index Tuning Class

I love continuing my education in SQL Server.  Recently I was fortunate enough to take Brent Ozar’s 3-day live online Master Index Tuning training class.

Since I had never taken an online class before, I thought it’d be fun to write a mini-review of what I thought about the… Read more

0 comments, 2,377 reads

Posted in Bert Wagner on 12 June 2018

4 Ways To Define Lookup Values In A Query

Watch this week’s episode on YouTube.

Occasionally you may need to create a lookup table of values for a single query.  Building a permanent table of these values is a good option if you need to reuse the values frequently, but for one-off, ad-hoc queries you may want to… Read more

6 comments, 3,367 reads

Posted in Bert Wagner on 5 June 2018

Older posts