The Bit Bucket

SQL: Where did my Reporting Services templates disappear to in VS2017?

I’m always telling students that one of the first things you need to learn to do when working with SQL Server Reporting Services (SSRS) is to create report templates.

Now I really wish that SSRS had a real templating system, but what we have at present is just a folder that contains the items that we can create. For example, in an SSRS project, if I right-click Reports, and click Add, then New Item:

2018-06-12

SQL: SELECT TOP 100 PERCENT is a code smell for SQL Server

We help a lot of customers upgrade their systems. Part of that job involves looking for code smells before starting the upgrades. If you aren’t familiar with code smells, this Wikipedia article explains it pretty well: https://en.wikipedia.org/wiki/Code_smell.

Specifically, they describe a code smell as any characteristic in the source code of a program that possibly indicates a deeper problem.

One of these is the presence of TOP 100 PERCENT or perhaps written as TOP (100) PERCENT in SELECT queries. Almost always, we see this in the definition of views.

2018-06-11

ML: Properties of the LaunchPad service - changing the concurrent session limit

In a recent post, I discussed issues I found when testing the Machine Learning Services setup in SQL Server 2017.

After that, my old friend Niels Berglund also posted about issues he found after installing CU7 (cumulative update 7) and how he solved them. Niels’ article is here: http://www.nielsberglund.com/2018/06/01/sql-server-machine-learning-services-and-sql-server-2017-cu-7/

What each of those articles discussed though was detail on how temporary files are used by Machine Learning Services in SQL Server to hold R or Python data for sessions. By default, SQL Server configures itself to hold data for up to 20 concurrent sessions.

2018-06-08

SDU Tools: SQL Server Version for Compatibility Level

While SQL Server includes an amazing array of built in functions and procedures, one that’s always puzzled me is the lack of a simple function to convert a database compatibility level to a SQL Server version ie: how do you know that 110 was SQL Server 2012?

And so, you don’t need to wait any longer.

One of the tools in our free SDU Tools collection for database developers and DBAs is SQLServerVersionForCompatibilityLevel.

2018-06-06

Opinion: When does NULL make sense for database columns

One thing that seems to get developers hot under the collar is whether their database columns should be nullable or not.

As mentioned in earlier posts, some try to just have everything NOT NULL to avoid dealing with the issue. But that can lead to the use of magic values where you store a value that means “there is no value” just to avoid the value being NULL. The problem with magic values is that every layer of code needs to know what’s happening. These values inevitably leak into the outside world.

2018-06-05

SQL: Avoiding hard-coding T-SQL procedure names within procedure code

When developers are creating SQL Server stored procedures in T-SQL, I often see them embedding the name of the procedure as a hard-coded string within the procedure itself. Here’s a rough example:

The problem here is that if the procedure gets renamed, you then need to go and find every reference to it throughout the code.

The solution is to get the procedure name programmatically and use that:

2018-06-04

DevOps: Deleting stored procedures and views in target database when using database projects

We’ve been using SQL Server database projects ever since they were called “Visual Studio Team Edition for Database Professionals”. That was back in 2005 and the name was quite a mouthful.

Until the last year or so though, we’ve only seen fairly patchy adoption of them among our customers. Over the last year or so, this has really changed. We’re seeing so many customers starting to use them. Why?

I’m guessing that it’s the increased interest in using DevOps.

2018-06-01

Shortcut: Using dark theme in SQL Server Management Studio (SSMS)

SQL Server Management Studio (SSMS) is based on the Visual Studio shell. What is puzzling sometimes is that features that are present in Visual Studio are not present in SSMS. One of these relates to themes. “Out of the box”, Visual Studio looks like this:

When you write code, the windows look like this:

Some people don’t like the “whiteness” of the whole screen and find darker colors easier to work with for long periods. In Visual Studio, you can change this. In Tools, then Options, you can change the theme:

2018-05-31

SDU Tools: ReservedWords, FutureReservedWords, ODBCReservedWords, SystemDataTypeNames, SystemWords

One of the things that I’ve always thought was missing in SQL Server and the T-SQL language was a built-in view that showed reserved words, and even better, future reserved words.

It’s one thing to say that you can create a policy to avoid people using reserved words for table, column, or object names, but how exactly do you know that the name you’ve chosen is one of those?

We decided to tackle that with one of our free SDU Tools for database developers and DBAs.

2018-05-30