Saturday, 25 December 2010

Merry Christmas


Dim msg
if date() = "25/12/2010" then
   msg = "Where's Santa?"
end if
Response.write msg

Friday, 24 December 2010

Should I close the blog for Christmas holidays?


That's a question, isn't it? I've been struggling finding the answer for a week or so and I've reached a conclusion. 

The Web Thought will be closed for Christmas.

I will restart posting on January the 10th.
That's a loooong time. Will you resist?

Have a nice and splendid Christmas time, enjoy yourself, stay with your family and forget about programming for a while.

Wednesday, 22 December 2010

HTML: How to create bar charts with tables


In this post I will explain a very - very! - simple method to create vertical or horizontal bar charts using only HTML. You already know that on the web you can find many different solutions to create charts. In October, I  posted a list of jQuery plugins and I know there are other JavaScript snippets or Flash stuff available to draw graphs. However I've always found hard to apply those solutions to my needs. That is because I wanted to use data from a database, while many of the available snippets get the data from txt or xml files.

Monday, 20 December 2010

ASP: The Response.Flush method


Experience in programming is something that comes with time. You always learn something new, especially when you need to solve an issue. Sometimes, having a problem, a syntax error thrown by your favourite browser, could be the right moment to learn a new trick. Solved the problem, you might soon forget about the solution, or you might forget to understand better the solution. That is what happened to me with Response.Flush and in this post I would like to get a deeper look at it.

Friday, 17 December 2010

SQL Server: basic functions (part 9) - Substring


One of the most interesting Sql function, when working with strings, is Substring. Basically, it returns a part of a string, given the starting point and the length (number of characters).

The syntax
Let's see Substring syntax:
SUBSTRING ( expression , start , length )
In the function we have to declare:
  1. expression, which is the string we want to manipulate;
  2. start, which is an integer or bigint indicating where to start the extraction. If it is 0 (zero), the starting point will be at the beginning of the expression -1 (see below in "examples"). If start is greater than the length of expression, the function will return a zero-length expression;
  3. length, which is a positive integer or bigint indicating how many characters to consider from the start (starting point).

Wednesday, 15 December 2010

CSS: create a footer (header) for your asp page


I write this post because someone asked me how to create footer in an asp page. That's the main reason. However, after writing a lot about Sql Server functions (and I don't think I am really finished with that!), I indeed needed a break. Anyway...
Creating a footer for your asp page is very easy. I will show you how to do it with css styles, assuming you have a default.asp page which is your home page, an include named footer.asp which is your footer and an external css.css page containing your styles.

Monday, 13 December 2010

SQL Server: basic functions (part 8) - @@IDENTITY


In this post I will introduce you a very tricky and useful function called @@IDENTITY. The function returns the last inserted identity value. As you may already know, the identity column in a Sql Server table is a numeric column that auto increments when a new value is inserted in the table itself. To put it simply, it is the ID column in your table. Now, what is the practical use of @@IDENTITY?

Friday, 10 December 2010

SQL Server: basic functions (part 7) - IsNull, IsNumeric, IsDate


This is the seventh part of the Sql Server basic functions series. When I started it, I couldn't think of going that far. Honestly, I thought I would write about some functions, however, after a while, I started to understand that leaving other functions out would be unfair. That's why I would like to write about IsNull, IsNumeric and IsDate... and maybe some other functions in the near future.

Wednesday, 8 December 2010

SQL Server: basic functions (part 6) - Coalesce


Have you ever thought "what is COALESCE afterall?". The first time I encountered it, I thought it was a terrible name for a function. But, considering that a normal dictionary will define "coalesce" as "Come together and form one mass or whole" or "Combine (elements) in a mass or whole", that might shed a little light and help us understand what's behind the function.

Monday, 6 December 2010

SQL Server: basic functions (part 5) - Aggregation


Aggregate functions are used in SQL Server queries to perform operation on a group of values and returns one single value as result. Aggregate functions are used with the SELECT statement, with the GROUP BY and the HAVING clauses.
There are different aggregate functions, however the most important are:
  • Count
  • Sum
  • Avg
  • Min
  • Max
And those are the functions we are going to see here.

Friday, 3 December 2010

SQL Server: basic functions (part 4) - Dates


Dates! Working with dates in Sql Server queries might be fun... or not... It's a fact that sooner or later everybody will end up dealing with date manipulation. Sql Server comes with different date functions which can help us through the process. In this article we are going to see:
  • datepart
  • day, month, year
  • datename
  • getdate
  • dateadd
  • datediff

Wednesday, 1 December 2010

SQL Server: basic functions (part 3) - Cast and Convert


Following the other 2 parts of the series, in this short article we are going to see how to convert data in a query.

Cast and Convert: why 2 functions?
Cast and Convert are two functions used to convert data. I've always been confused by the fact that there are actually 2 functions to - apparently - perform the same operation. First of all, I must say that CONVERT can be used only in Sql Server while CAST derives from the ANSI standard. Wow! And so? CONVERT is undoubtedly more flexible while CAST is in a way a standard, it is more portable (it works in almost in any db environment), but it is less powerful. On top of that, CAST is preferably used when converting between decimal and numeric values to preserve the number of decimal places.