Sql-Server

SDU Tools: Converting T-SQL Strings to PascalCase or camelCase

I’ve often had requests for code to convert strings to ProperCase and I described that in a recent blog post, but another common request is for either PascalCase or camelCase.

In PascalCase, all spaces between words are removed, the first letter of each word is capitalized, and the other letters in each word are lower case.

You can see it in this example:

camelCase is similar except that the first letter of the first word is not capitalized. The first letter of subsequent words are capitalized:

2017-12-15

Shortcut: Using Database Snapshots to Provide Large Unit Testing Data with Quick Restores

SQL Server databases have a reputation for being hard to test, or at least hard to test appropriately.

For good testing, and particularly for unit tests, you really want the following:

  • Database in a known state before each test
  • Database containing large amounts of (preferably masked) data (production-sized)
  • Quick restore after each test before the next test

For most databases, this is hard to achieve. The restore after each test means that a normal database restore can’t be used. What I often see instead, is people using transactions to try to achieve this i.e. the process becomes:

2017-12-14

SDU Tools: Find String Within a SQL Server Database (Did you mask your database properly?)

I’ve mentioned that I work on a lot of financial systems. Masking and trimming the production databases so they can be used in development is important, yet I see many issues with masking.

A few months back, I was working on a SQL Server database from a large financial client, and the database was supposed to have been masked. However, what they missed was that the XML metadata associated with images stored in the database still had the actual client’s details. Any developer in the organization could have retrieved private details of all the members of the fund.

2017-12-13

Opinion: Why ask accountants and lawyers for IT advice?

If I want accounting advice, it’s unlikely that I’d ask my dentist for that advice.

Many years ago, I created applications for food wholesalers. When the owners of these businesses decided to get a new or better computing system, invariably they’d speak to their accountants. I understand the reasons why that might seem logical to them at first, but what I saw when these clients did this, is that they invariably ended up with the wrong systems.

2017-12-12

SQL: Database Design -> What's in a Name?

Just after I was born, my mother and father called me Gregory. Ever since then, everyone has called me Greg. And that included my parents. To this day, my mother calls me Greg and so did my dad while he was alive (miss you dad).

However, every time I need to fill in an official form, I have to write Gregory. I could change that to Greg if I changed my name legally but I’m not going to do that. People who have had previous names will tell you that can add even more complexity.

2017-12-11

SDU Podcast: Show 73 with Principal Architect Bob Ward

I’ve known Bob Ward for almost as long as I’ve been involved with SQL Server. (I first started in 1992). Bob is one of the constants in the SQL Server team, is deeply technical, and his continuing passion for the product is apparent.

I’ve been wanting to get Bob onto  a podcast for a long time and we finally managed to do so today.

Bob is currently a principal architect with the SQL Server engineering team, focused on architecture, customer success, and technical evangelism of SQL Server.

2017-12-09

SDU Tools: Split a Delimited String (like a CSV) Into Columns Using T-SQL

I recently wrote about the tool we provide for splitting T-SQL delimited strings (like CSVs or comma-delimited strings). It outputs a row for every value.

Sometimes, however, I’m asked how I can get each value out into a separate column. Now that’s a little trickier without dynamic code because SQL Server wants to know the output metadata of the statement. SQL Server wants to know in advance what the output columns are called and what their data types are. This is especially important if you want to consume the output of the function in tools like SQL Server Integration Services (SSIS) or Biztalk.

2017-12-08

Shortcut: Using Templates in SQL Server Management Studio (SSMS)

A week or so ago, I wrote about how to use Snippets in SQL Server Management Studio (SSMS) when you can’t remember the syntax of how to create objects in T-SQL.

Snippets were added reasonably recently compared to templates, which are more appropriate when you are creating an entire script file for a new object. They are easy to use too yet because they don’t appear on the screen by default, many people don’t even realize that they are there. Let’s take a look.

2017-12-07

SDU Tools: New T-SQL Statement: STRING_SPLIT plus Split Delimited String Tool

I’ve mentioned that I love it when SQL Server gets new T-SQL functionality.

A useful function that was added in SQL Server 2016 was STRING_SPLIT. You can see it in action in the main image for this post.

It’s another function that is great as far as it goes, but when I was a kid, this would be described as “nice try but no cigar”.

It works, and it’s fast, so what’s missing. I think two things:

2017-12-06

Opinion: Don't Design Databases for One Version of One App

I’ve pointed out in previous blog posts that I’m not a fan of ORMs. What I’m even less of a fan of is code-first design, particularly in combination with an ORM like the Entity Framework.

It might seem cool and shiny and if you are just whipping up a small proof of concept or test app, please feel free to do it, but the minute you think of doing it for enterprise systems, just don’t. And if you have colleagues wanting to do this, please just say no.

2017-12-05