I’m converting DATETIME values to string nearly every day when doing regular T-SQL development. After years I remember a lot of format parameter values to get the right string representation of input DATETIME value. But still time to time something…
Rounding DATETIME values to midnight
5. 8. 2014
DATETIME data type precision for milliseconds is rounded to increments of .000, .003, or .007 which leads to some unexpected behavior from time to time. I.e. if we will try to extract at which day event logged with milliseconds occurred….
ISNUMERIC()? No, thank you!
2. 6. 2014
Can we trust ISNUMERIC() function when checking if it is safe cast string value to numeric data type? Definitely not, because it´s more or less unusable for this purpose, because we can´t be sure what is hidden in string to…
Examples of TOP syntax
21. 5. 2014
This article is just a short summary of TOP clause variants we can use. Especially the last one with a subquery isn’t so common and can be something new for you. Consider official documentation for more details on TOP usage…
It´s legitimate expectation that a SELECT statement will return consistent results independently on number of rows returned or an internal implementation of query processing. But it is not always true. I will demonstrate it on a simple query using NEWID()…
Composable DML
27. 4. 2014
Composable DML is an extension SQL Server 2008 extension of the OUTPUT clause which one was originally published in SQL Server 2005. OUTPUT is generally returning all rows from the DML where it’s used without an option to filter the…
How to prevent views with outdated metadata?
23. 8. 2013
SQL Server is persisting various metadata when a new view is created in SQL Server. When underlying objects are changed later then view metadata aren’t updated automatically and this outdated metadata can cause several issues later. Let’s see one simple…