February 2005 - Posts

This new feature of the FROM clause allows you to select a sampling of data rows (either a percentage or a number of rows).  Note: the number of rows it returns is completely approximated.



This modifier is useful when you just want to see a sampling of the table, but not necessarily the items at the top of the query.

One of the features I wanted added most to SQL Server 2005 is here.  In the past if you were using the TOP clause with a SELECT statement, you could only specify a constant value (i.e.: SELECT TOP 20 FROM Blah).   Now, the SELECT statement supports variable TOP statements, like the following:
DECLARE @NumberRecords int
SET @NumberRecords = 20
SELECT TOP @NumberRecords FROM blah
This can also be used with PERCENT as well.  For example:
DECLARE @TopPercentage int
SET @TopPercentage = 10
SELECT TOP (@TopPercentage) PERCENT FROM blah
There have been multiple times in which I wish I could have done this with SQL Server 2000, so this is a nice addition.
One of ASP.NET 2.0's new features is the ability to do Post-Cache substitution.  This basically allows you to override a portion of a cached page with dynamic content.  There are multiple ways of doing this, but one of the easiest ways to do it on a page or user control is to use the Substitution control.  All this control, really does is call a custom method that you specify to render that porition of the page. 
<%@ outputcache duration="60" varybyparam="none" %>
   <form runat="server">
      Cached Content
      <%-- Get dynamic porition of the page %>
      <asp:substitution id="SubstitutionControl" runat="server" methodname="GetDynamicContent" /> 
      Cached Content
The method the substitution control calls would look like this:
protected static string GetDynamicContent(HttpContent httpContext)
    return "Non-Cached Dynamic Content";
This control will prove to be useful any time we have a page that isn't 100% static.
This seems like it is a little late in the game to implement this, but the AdRotator control now supports an AdType property.   This property can be set to popup or popunder.  So now, you can use a builtin control to make your site as annoying as possible.  Ironically, they add this feature, after they intergate a popup blocker into Internet Explorer.   Just specify the PopPositionTop and PopPositionLeft properties to specify where the popup will appear.
<asp:AdRotator ID="AdRotator1" Runat="server" 
  DataSourceID="Ads" AdType=Popup PopFrequency="50" 
  PopPositionLeft="100" PopPositionTop="100" 
<asp:XmlDataSource ID="Ads"
The control now also supports ASP.NET 2.0 databinding.  Therefore you are no longer constrained to using an XML file, you can use any datasource as long as it returns data in the required schema used by the AdRotator control.
Here is another new control added by ASP.NET 2.0.  This data bindable control renders a bulleted list.  On top of that you can specify a bullet style (plain text, hyperlinks, or LinkButtons).  I am not sure if this control will ever be useful, but it's out there if you need it.
This is another one of those controls that now derives from WebControl instead of HTMLControl.
In the past you would have to do something like:
<input type="hidden" id="HiddenFieldControl" runat="server" />
Now you can use a hidden field, by doing:
<asp:HiddenField id="HiddenFieldControl" runat="server" /?
More Posts « Previous page