LessThanDot Site Logo

LessThanDot

A decade of helpful technical content

This is an archive of the posts published to LessThanDot from 2008 to 2018, over a decade of useful content. While we're no longer adding new content, we still receive a lot of visitors and wanted to make sure the content didn't disappear forever.

Restoring multiple transaction log backups

If you’ve ever had to restore log files and not use the restore to a point in time option, I’m sure you found it to be a pain executing all the restore statements. A good tip when you have to do this is to use vbscript or some other scripting technology to create your own .sql file that you can just execute and restore the .trn files So for example, I use Quest Litespeed for compression (see here for more info).

Read More...

Dealing with the could not allocate new page for database 'TEMPDB'. There are no more pages available in filegroup DEFAULT error message

Someone was writing some queries that brought back a lot of data (and I mean a LOT!!) and after a while he got the following message Connectivity error: [Microsoft][ODBC SQL Server Driver][SQL Server]Could not allocate new page for database ‘TEMPDB’. There are no more pages available in filegroup DEFAULT. Space can be created by dropping objects, adding additional files, or or allowing file growth That is not good, fortunately this wasn’t one of our production machines but a dev/test box.

Read More...

Bringing your thoughts back into line

I’m going to try my best at this topic even knowing I have my own issues with it on several occasions. I was recently reminded of the stress and focus issues we have in IT. This goes as far as questioning our abilities, accomplishments and future goals in life regarding our careers. I myself have to admit that I go through this once in a while. Our fields are probably the most stressful and short lived in the workforce.

Read More...

The differences between LEN and DATALENGTH in SQL Server

The differences between LEN and DATALENGTH in SQL Server! I have seen a bunch of questions about this recently and decided to do a little post to clear up the confusion. First let’s take a look what Books On Line has to say about these two functions LEN Returns the number of characters, rather than the number of bytes, of the given string expression, excluding trailing blanks. DATALENGTH Returns the number of bytes used to represent any expression.

Read More...

Setting SQLDataSource parameter from the code-behind

One of the often asked questions on ASP.NET forum I visit is how to change SQLDataSource parameter. I know two common solutions to this problem, though I only tried one in my own web-pages. I’ve just learned about another interesting solution which is presented in Peter Kellner’s blog. See also another blog discussing this approach. The solution I’m familiar with and used is to set the parameter in Selecting (Inserting / Updating for Insert / Update) events of SQLDataSource.

Read More...

Including an Aggregated Column's Related Values

In this co-authored blog post, Naomi and I will present six different solutions to the commonly experienced query problem of how to include an aggregated column’s related values – values from the same row in the group that provided the displayed value. Background It’s a fairly simple query to select the maximum date for each group in a GROUP BY query. You just throw in a Max() on the date column and then GROUP BY the other columns.

Read More...

Ecofont, Will this save the planet?

I saw this in National Geographic magazine 2 days ago and found it a bit interesting. Take a look at this font below You probably noticed the holes in the letters, if you print this out you will save ink. According to the Ecofont website you can save up to 20% of ink After extensive testing with all kinds of shapes, the best results were achieved using small circles.

Read More...

C# case sensitivity

I spent the better part of two weeks trying to troubleshoot an issue that was causing some problems. Essentially, information within the system was not being properly routed based on specific criteria. When I received the case, the issue had apparently been fixed for the customer in question so, when I attempted to recreate the problem on my local box, I was unable to reproduce it. Instead, I tried stepping through the code (which is pretty complex C# code) and then looking at the data and relevant stored procedures in the back-end SQL database.

Read More...

IsNumeric, IsInt, IsNumber

Occasionally, it’s necessary to convert character data (char, nchar, varchar, nvarchar) to a number. Before doing so, it is best to make sure that the value can be converted to a number. IsNumeric would be the obvious choice, but has some problems because it allows for unexpected characters during the conversion. For example, the following strings will return true from the IsNumeric function. $12.09 1.4e3 2d4 Technically, all of these are numbers.

Read More...

Operand type clash: date is incompatible with int error when trying to do +1 on a date data type in SQL Server 2008

I have seen enough questions about this lately and this means that it is time for a blogpost. SQL Server 2008 has a bunch of new data types and one of them is the date datatype. If you don’t care for the time portion of the date you can now use the date data type and save 5 bytes per row compared to datetime. I know that there is smalldatetime which only takes up 4 bytes but I myself could not use that because we have data that goes back to 1896 and thus can’t be stored in smalldatetime

Read More...