Sql-Server

Certification: Q: When will the new SQL Server certifications come out? A: They won't

I’ve had a number of people asking me lately about what’s happening with SQL Server certifications. There are a number of clients that I deal with, where they require their staff to regularly update their certifications. It’s been part of their ongoing commitment to training.

In particular, I’m asked When will the new SQL Server certifications be available?

And the (perhaps surprising for some) answer is: They won’t be.

The way that Microsoft certifies people has gone through a seismic shift. The entire focus is now on certifying people’s ability to perform roles, rather than their ability to use a particular product.

2020-04-28

T-SQL 101: 67 Literal date and time values in SQL Server T-SQL

One of the challenges when you go to write dates is that there’s no standard format in SQL Server for how to write a date. Some other languages have a specific format for writing dates. In T-SQL, we have to write it as a string.

Because there’s no special way to write dates, it’s very important to come up with a format that will work properly all the time. The example I’ve got here for OrderDate is 20190128. That is a safe format that always works. SQL Server will interpret it as YYYYMMDD every time, no matter what regional or language settings you have configured.

2020-04-27

SQL: Shrinking SQL Server Databases usually isn't a good plan

I remember when SQL Server 7 was released, it was such a big deal that you could easily grow and shrink database files, and indeed, you could have databases auto-grow, and, auto-shrink. That seemed pretty appealing if you wanted a low maintenance solution.

If only life was so simple.

One of the real challenges of auto-grow and auto-shrink is that you could have a database constantly changing size up and down, and that’s quite nasty, because each time you grow, you’re often using a different part of your file system.

2020-04-23

SDU Tools: Start of Working Week and End of Working Week in SQL Server T-SQL

I mentioned in my last SDU_Tools post that I get really good feedback all the time from users of our free SDU Tools for developers and DBAs, but none more than when we have more and more date and time functions. Another pair of functions that we added in v19 that was recently shipped was StartOfWorkingWeek and EndOfWorkingWeek.

These are simple scalar functions that take a single date parameter, and return the date for the Monday and the Friday of the week that contains the date provided.

2020-04-22

T-SQL 101: 66 Date and time data types in SQL Server T-SQL

While there are some other data types that I’d like to see added (for example a month data type), SQL Server has quite a rich set of date and time data types. Some of these were older data types and some new ones were introduced in SQL Server 2008.

An important one that was added in 2008 is the date data type. It’s just a date. It has no time associated with it and it covers year from 1 to 9999. It says that it’s based on the Gregorian calendar (i.e. our current calendar) but that’s a bit ambitious given it didn’t exist back in the year 1. But for the range of dates that we would work with, this will always work fine.

2020-04-20

SQL: Why I prefer sequences to IDENTITY columns

I posted the other day that I don’t like negative ranges used for IDENTITY columns. I feel the same about the range of values for sequences, but when I mentioned that I prefer using sequences, a few friends asked why I preferred them.

Let me start by saying that I was surprised with the previous post, that the strong responses were about using natural vs surrogate keys. That had nothing to do with what I was discussing, and is an endless topic for another day. The issue was about when someone has already decided to use an IDENTITY or a sequence. And so, the same point applies to this discussion.

2020-04-17

SQL: Don't start identity columns or sequences with large negative values

This week, one of my colleagues was complaining that he had to do work on a database where every table had identity columns, and they all started at large negative values.

I remember some people promoting this years ago, to double the available numeric range for the data types, rather than just using positive values.

I didn’t like it when I saw it then, and I still don’t like it.

2020-04-16

SDU Tools: Start of week and End of week in SQL Server T-SQL

I get really good feedback all the time from users of our free SDU Tools for developers and DBAs, but none more than when we have more and more date and time functions. One pair of functions that we added in v19 that was recently shipped was StartOfWeek and EndOfWeek.

These are simple scalar functions that take a single date parameter, and return the date for the start and end of the week that contains the date provided.

2020-04-15

T-SQL 101: 65 Formatting strings in SQL Server T-SQL using FORMAT

In upcoming blog posts, I’ll show you how to change from one data type to another. I’ll show you how to use CONVERT to output date/time values to string formats.

If you look at the web page for CAST and CONVERT, you’ll notice there are many styles for conversion. For example, the US format is called 101 if it has a 4 digit century. But it’s called 1 if you only have a 2 digit century. Another very common one is the British/French one and that’s 103 for a 4 digit century or just 3 for a 2 digit century.

2020-04-13

Version 19 of our free DBA and Developer tools has now shipped

I just wanted to give everyone a heads-up that we recently shipped version 19 of our free SDU Tools for developers and DBAs to our SDU Insiders.

We’re pretty happy with this new version and it includes Azure SQL Database support as well as SQL Server.

So what’s changed?

Version 19 includes the following enhancements:

DatesBetweenNoWeekends - A new version of our DatesBetween function that excludes weekends InitialsFromName - Extracts someone’s initials from their name (with/without a separator) DateDimensionPeriodColumns - We’re really proud of this one. It completely enriches your date dimensions with period logic. I’d encourage you to watch the video for this one. StartOfYearEndOfYearStartOfWeekEndOfWeekStartOfWorkingWeekEndOfWorkingWeek - more date calculations that do what their names suggest CurrentSessionDecimalSeparator - works out what the decimal separator is in your session CurrentSessionThousandsSeparator - does the name for the thousands separator StripDiacritics - Strips diacritics (accents, graves, unlauts, etc.) from a string DateTime2ToUnixTimeUnixTimeToDateTime2 - New functions for conversion to/from Unix times TimezoneOffsetToHours - Converts a timezone offset to a decimal number of hours

2020-04-12