<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Anatoly Lubarsky</title><link>http://blogs.x2line.com/al/</link><description>MSSQL, .NET, Design. Life and Music </description><managingEditor>anatolyl@gmail.com</managingEditor><dc:language>en-US</dc:language><generator>Version 0.97.2006.1</generator><image><url>http://blogs.x2line.com/Images/x2line_logo_feed.jpg</url><title>x2line: Social Network Services, Weblog Hosting</title><link>http://blogs.x2line.com/</link></image><item><dc:creator>Anatoly Lubarsky</dc:creator><title>T-SQL: Get Filename from Filepath</title><link>http://blogs.x2line.com/al/archive/2008/06/27/3475.aspx</link><pubDate>Fri, 27 Jun 2008 03:13:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/06/27/3475.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3475.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/06/27/3475.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3475.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3475.aspx</trackback:ping><description>&lt;p&gt;Many times applications store operating system paths to files in the database. And sometimes need to get only &lt;i&gt;Filename&lt;/i&gt; portion out of &lt;i&gt;Filepath&lt;/i&gt; column in MSSQL. How to do that ?&lt;/p&gt;&lt;br /&gt; 
&lt;p&gt;Disclaimer: I know - it's much easier to get the filename using C#, however many times we need to get the list of filenames filtered/grouped by some criteria.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Since there is no split function analog in T-SQL - I will use &lt;b&gt;SUBSTRING&lt;/b&gt;, &lt;b&gt;REVERSE&lt;/b&gt; and &lt;b&gt;CHARINDEX&lt;/b&gt; to manipulate strings:&lt;/p&gt;&lt;br /&gt;
&lt;pre&gt;
SELECT REVERSE(SUBSTRING(REVERSE(@fpath), 0, CHARINDEX('\', REVERSE(@fpath), 1)))
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;Enjoy :)&lt;/p&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3475.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anatoly Lubarsky</dc:creator><title>ASP.NET: How to Bind RSS Feed To Repeater</title><link>http://blogs.x2line.com/al/archive/2008/06/21/3469.aspx</link><pubDate>Sat, 21 Jun 2008 14:18:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/06/21/3469.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3469.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/06/21/3469.aspx#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3469.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3469.aspx</trackback:ping><description>&lt;p&gt;Repeater seems to be the easiest, light, most simple and generic control in ASP.NET to render repeated items. For example in data driven applications it is easy to render table contents (i.e. table rows) with Repeater. All developer needs to do is to bind a custom class collection, Array, List&lt;t&gt; or whatever to the Repeater.&lt;/t&gt;&lt;/p&gt;&lt;br&gt;
&lt;p&gt;However one can feel some lack of support in Repeater for RSS feeds in other words it is not easy to bind repeated to dynamic online XML structure like RSS.&lt;/p&gt;&lt;br&gt;
&lt;p&gt;Below I tried to demonstrate a small and simple example of how to bind RSS feed to ASP.NET Repeater control on the fly. It's implemented as a control which we can drop anywhere on ASP.NET page.&lt;/p&gt;&lt;br&gt;
&lt;pre&gt;&lt; %@ Control Language="c#" AutoEventWireup="true" EnableViewState="false" %&gt;
&lt; %@ Import namespace="System.Xml" %&gt;
&lt; script runat="server" language="C#"&gt;
    public string rssUrl = "http://blogs.x2line.com/al/rss.aspx";
    private System.Xml.XmlDocument doc;
   
    public override void DataBind()
    {
        doc = new System.Xml.XmlDocument();
        doc.Load(rssUrl);
         
        base.DataBind();
    }
         
    public void Page_Load(System.Object s, System.EventArgs e)
    {
        this.DataBind();
    }
&lt; /script&gt;

&lt; asp:Repeater 
    runat="server" 
    id="rptrRss" 
    DataSource='&lt; %# doc.SelectNodes("/rss/channel/item[position()&lt;=5]") %&gt;'&gt;
    &lt; HeaderTemplate&gt;
        &lt; div&gt;
            &lt; a href='&lt; %# doc.SelectSingleNode("/rss/channel/image/link").InnerText %&gt;'&gt;
            &lt; img 
                src='&lt; %# doc.SelectSingleNode("/rss/channel/image/url").InnerText %&gt;' 
                alt='&lt; %# doc.SelectSingleNode("/rss/channel/image/title").InnerText %&gt;' /&gt;
            &lt; /a&gt;
    &lt; /HeaderTemplate&gt;
    &lt; ItemTemplate&gt;
        &lt; a 
            href='&lt; %# (Container.DataItem as XmlNode)["link"].InnerText %&gt;'&gt;
            &lt; %# (Container.DataItem as XmlNode)["title"].InnerText %&gt;
            (&lt; %# (Container.DataItem as XmlNode).SelectSingleNode("author |
title[not(../author)]").InnerText %&gt;)
        &lt; /a&gt;
    &lt; /ItemTemplate&gt;
    &lt; FooterTemplate&gt; 
        &lt; /div&gt;
    &lt; /FooterTemplate&gt;
&lt; /asp:Repeater&gt;
&lt;/pre&gt;&lt;br&gt;
&lt;p&gt;Maybe useful to make widgets. Enjoy :)&lt;/p&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3469.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anatoly Lubarsky</dc:creator><title>Bathroom Stall Vandalism - 3000 Users on BEBO</title><link>http://blogs.x2line.com/al/archive/2008/06/15/3462.aspx</link><pubDate>Sun, 15 Jun 2008 23:11:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/06/15/3462.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3462.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/06/15/3462.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3462.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3462.aspx</trackback:ping><description>&lt;p&gt;&lt;img src="http://photos-b.ak.facebook.com/photos-ak-sf2p/v250/89/66/500491268/n500491268_896017_527.jpg" alt="Bathroom Stall Vandalism" /&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;a href="http://www.bebo.com/Profile.jsp?MemberId=5409925639"&gt;Bathroom Stall Vandalism&lt;/a&gt; on BEBO has passed 3000 users. Previous 2000 mark was back in April - &lt;a href="http://blogs.x2line.com/al/archive/2008/04/22/3405.aspx"&gt;Bathroom Stall Vandalism - 2000 Users on BEBO&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Speaking of which - &lt;a href="http://apps.facebook.com/bsv-gallery/"&gt;Bathroom Stall Vandalism Gallery&lt;/a&gt; was launched on Facebook this weekend. &lt;a href="http://apps.facebook.com/bsv-gallery/"&gt;Bathroom Stall Vandalism Gallery&lt;/a&gt; is supposed to complement &lt;a href="http://www.facebook.com/applications/Bathroom_Stall_Vandalism/5180194285"&gt;Bathroom Stall Vandalism&lt;/a&gt; on Facebook which growth is somewhat slow lately (comparing to that on BEBO). More Bathroom creative screenshots will be posted soon.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Enjoy&lt;/p&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3462.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anatoly Lubarsky</dc:creator><title>How to: Get Total Physical Memory</title><link>http://blogs.x2line.com/al/archive/2008/06/14/3459.aspx</link><pubDate>Sat, 14 Jun 2008 05:59:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/06/14/3459.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3459.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/06/14/3459.aspx#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3459.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3459.aspx</trackback:ping><description>&lt;p&gt;Q: My app needs to know how much RAM the machine it's running on has. How can this information be aquired ?&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Is there any _managed_ way of getting total physical memory installed in the machine ?&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;You can retrieve the amount of physical memory on the computer by using WMI (You could use a WMI query, the property is "TotalPhysicalMemory" which is in the "Win32_ComputerSystem" class.). However: WMI would  almost always be the slowest way to retrieve system values using C#.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Therefore I advice to use Win32 API - &lt;b&gt;GlobalMemoryStatus&lt;/b&gt; function included in &lt;i&gt;kernel32.dll&lt;/i&gt;:&lt;/p&gt;&lt;br /&gt;
&lt;pre&gt;
public struct MemoryStatus 
{ 
    public uint Length;  
    public uint MemoryLoad; 
    public uint TotalPhysical; 
    public uint AvailablePhysical; 
    public uint TotalPageFile; 
    public uint AvailablePageFile; 
    public uint TotalVirtual; 
    public uint AvailableVirtual; 
} 

[DllImport("kernel32.dll")] 
public static extern void GlobalMemoryStatus(out MemoryStatus stat);
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;From managed code we can use it  like so:&lt;/p&gt;&lt;br /&gt;
&lt;pre&gt;
MemoryStatus stat = new MemoryStatus();
GlobalMemoryStatus(out stat);
long ram = (long)stat.TotalPhysical;
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3459.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anatoly Lubarsky</dc:creator><title>Break Machine - Street Dance</title><link>http://blogs.x2line.com/al/archive/2008/06/06/3447.aspx</link><pubDate>Fri, 06 Jun 2008 02:09:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/06/06/3447.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3447.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/06/06/3447.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3447.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3447.aspx</trackback:ping><description>&lt;p&gt;I always thought that 80s was the music era. Music industry has never reached the amount of talent since then. My theory is that in 80s it was music where most talented would try to go to express themselves. in 90s and 2000s it is IT and internet industry which possess most talented people. In 50s and 60s it was like science - physics (?).&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;So I decided to post some 80s classics - "Street Dance" by Break Machine (with Fred Zarr on the keyboards).&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/rGkIUlYEQT8&amp;hl=en"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/rGkIUlYEQT8&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;i&gt;"...music such as this gets remembered and praised because it is history..."&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Enjoy&lt;/p&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3447.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anatoly Lubarsky</dc:creator><title>Natural Key vs. Surrogate Key - Userid in Social Networks</title><link>http://blogs.x2line.com/al/archive/2008/05/30/3445.aspx</link><pubDate>Fri, 30 May 2008 13:36:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/05/30/3445.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3445.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/05/30/3445.aspx#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3445.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3445.aspx</trackback:ping><description>&lt;p&gt;All of us (almost) are the members of different social networks: Facebook, Bebo, Myspace, Hi5, etc. We ARE users. User is a real entity - a real person.&lt;/p&gt;&lt;br&gt;
&lt;p&gt;One of the problems is the ability to identify a user in a unique way across the internet.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;There are 2 approaches to identify entity - both inherited from Relational database model.&lt;/p&gt;&lt;br /&gt;
&lt;h2&gt;Natural Key&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Natural_key"&gt;Natural Key&lt;/a&gt; - a key which has logical reference to (or the same as) already existing unique entity attribute(s). The key has to identify a real entity whose existence can be verified. The most common example is person national ID number, which identifies national passport (?) in a unique way. However the ideal candidate for the persons natural key would be some fictional Global Universe ID. For social networks the best candidate so far is users EMAIL address since:&lt;/p&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Email address is unique.&lt;/li&gt;
&lt;li&gt;Email identifies a user in a unique way across all common social networks. The same email represents the same user in Facebook, Bebo, Myspace, etc.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;p&gt;The problem: usually email address cannot be shared once this or another social network decides to open its platform and share the user data due to privacy issues. For example email address is not accessible within Facebook API. The second issue is that actually the same user can have several mail addresses, which makes it less trivial to identify the user. Should we use a combination of all user emails to be able to perform identification in a unique way or just use the primary email address ?&lt;/p&gt;&lt;br /&gt;
&lt;h2&gt;Surrogate Key&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Surrogate_key"&gt;Surrogate Key&lt;/a&gt; - a generated key which is not related to the entity attributes. Usually integer (INT or BIGINT, sometimes GUID). For example my userid on facebook is 500491268 and on bebo - 5282127447.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;i&gt;"Because the surrogate key is completely unrelated to the data of the row to which it is attached, the key is disassociated from that row. Disassociated keys are unnatural to the application's world, resulting in an additional level of indirection from which to audit."&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;As we can see the surrogate key is not unique across the internet. We get real problem when social networks (and their competitors) open their platforms to 3rd parties and decide to share the data. In order to identify the user in a unique way we need to scale the surrogate key to include another surrogate key which identifies the platform, but it remains still impossible to associate the same user on different platforms.&lt;/p&gt;&lt;br /&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Recently we can see how different social networks are trying to win and dominate the social network space by trying to develop Connect Schemas in order to make connect more sites and applications and make them use their surrogate key to identify users. Recent examples are: &lt;a href="http://www.facebook.com/news.php?blog=1&amp;amp;story=108"&gt;Facebook Connect&lt;/a&gt; and &lt;a href="http://www.google.com/friendconnect/"&gt;Google Friend Connect&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;I think this approach will not survive in the long run. The solution is the creation of something like Global Universe ID which identifies a person in the universe, globally and historically unique and shareable. LOL&lt;/p&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3445.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anatoly Lubarsky</dc:creator><title>MySql: Add a Column at a Specific Position</title><link>http://blogs.x2line.com/al/archive/2008/05/28/3437.aspx</link><pubDate>Wed, 28 May 2008 19:17:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/05/28/3437.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3437.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/05/28/3437.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3437.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3437.aspx</trackback:ping><description>&lt;p&gt;I'm playing with MySql for the 1st time in my life recently. Rather quickly I'm getting used to it mostly due to my experience with MSSQL as DBA.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;While changing table structure I just came across one interesting feature and decided to post about it.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;It is possible to use &lt;a href="http://dev.mysql.com/doc/refman/5.0/en/alter-table.html"&gt;MySql ALTER TABLE&lt;/a&gt; command and add a column at a specific position within a table row using AFTER command. MSSQL for example cannot do the same within ALTER TABLE and in order to perform such manipulation one need to create and drop temporary table.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;i&gt;"To add a column at a specific position within a table row, use FIRST or AFTER col_name. The default is to add the column last. You can also use FIRST and AFTER in CHANGE or MODIFY operations to reorder columns within a table."&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Example:&lt;/p&gt;&lt;br /&gt;
&lt;pre&gt;ALTER TABLE Product ADD Price DECIMAL(10, 2) NOT NULL AFTER ProductName;&lt;/pre&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3437.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anatoly Lubarsky</dc:creator><title>MSSQL 2008: Spatial Data Types - Geography and Geometry</title><link>http://blogs.x2line.com/al/archive/2008/05/15/3429.aspx</link><pubDate>Thu, 15 May 2008 02:28:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/05/15/3429.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3429.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/05/15/3429.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3429.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3429.aspx</trackback:ping><description>&lt;p&gt;In addition to &lt;a href="http://blogs.x2line.com/al/archive/2008/05/13/3426.aspx"&gt;new DATETIME data types&lt;/a&gt; introduced in MSSQL 2008 there are &lt;b&gt;geography&lt;/b&gt; and &lt;b&gt;geometry&lt;/b&gt; data types introduced - useful for storing and manipulating geodetic data. Geometry data type is used to store flat map data like points, lines, and shapes. Geography data type takes account of the curvature of the Earth in addition. Both provide the ability to perform spatial operations on geography instances. Geography and Geometry are likely to be supported in MSSQL 2008 Express versions.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;i&gt;"The ability to use the geography data type in a Microsoft SQL Server database enables you to extend business applications to handle geospatial data that describes simple and complex geographic elements on the surface of the Earth."&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Geography data type has functions which support parsing back from the known geo formats supported by the OGC (Open Geospatial Consortium) like text formats, binary representations, GML (Geography Markup Language - XML for geo data).&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Small example of spatial operations - let's assume we need to find the area (i.e. in square meters) of the stored polygons (SalesRegion of SalesPerson table). The query:&lt;/p&gt;&lt;br&gt;
&lt;pre&gt;SELECT SalesRegionName, SalesRegion.STArea()
  FROM SalesPerson
&lt;/pre&gt;&lt;br&gt;
&lt;p&gt;Other supported functions include &lt;b&gt;STIntersects()&lt;/b&gt;, &lt;b&gt;STUnion()&lt;/b&gt; for polygons and &lt;b&gt;STDistance()&lt;/b&gt; for points.&lt;/p&gt;&lt;br&gt;
&lt;p&gt;To boost performance one can &lt;a href="http://msdn.microsoft.com/en-us/library/bb934196%28SQL.100%29.aspx" target="_blank"&gt;CREATE SPATIAL INDEX&lt;/a&gt; for the data of GEOGRAPHY or GEOMETRY column.&lt;/p&gt;&lt;br&gt;
&lt;p&gt;Enjoy :)&lt;/p&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3429.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anatoly Lubarsky</dc:creator><title>MSSQL 2008: What is DATETIME2</title><link>http://blogs.x2line.com/al/archive/2008/05/13/3426.aspx</link><pubDate>Tue, 13 May 2008 19:13:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/05/13/3426.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3426.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/05/13/3426.aspx#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3426.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3426.aspx</trackback:ping><description>&lt;p&gt;MSSQL 2008 introduces several new DATETIME datatypes for T-SQL. It is obvious that TIME and DATE provide the ability to store separately DATE and TIME parts of DATETIME. It was not possible to do in previous versions of MSSQL, however it was possible to get either part of the DATETIME using DATETIME functions, for example a couple of years ago I posted about how to &lt;a href="http://blogs.x2line.com/al/archive/2006/02/17/1458.aspx"&gt;Get only Date from DateTime&lt;/a&gt;.&lt;/p&gt;&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;TIME&lt;/li&gt;
&lt;li&gt;DATE&lt;/li&gt;
&lt;li&gt;&lt;b&gt;DATETIME2&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;DATETIMEOFFSET&lt;/li&gt;
&lt;/ul&gt;&lt;br&gt;
&lt;p&gt;What is DATETIME2 ? It is an improved version of DATETIME. It we compare between them:&lt;/p&gt;&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Storage: DATETIME2 takes 6-8 bytes, DATETIME takes 8 bytes.&lt;/li&gt;
&lt;li&gt;Accuracy: DATETIME2 (100 nanosec), DATETIME (333 nanosec).&lt;/li&gt;
&lt;li&gt;Range: DATETIME2 (0001/01/01 - 9999/12/31), DATETIME (1753/01/01 - 9999/12/31).&lt;/li&gt;
&lt;/ul&gt;&lt;br&gt;
&lt;p&gt;Sounds cool. Except strange name used for the datatype...(LOL) Seems like folks in Microsoft copied  VARCHAR2 convention from Oracle which I didn't understand either.&lt;/p&gt;&lt;br&gt;
&lt;p&gt;DATETIMEOFFSET datatype is like DATETIME2 plus in addition it can store TIMEZONE in hh:mm while the actual datetime is stored in UTC. This datatype takes up to 10 bytes in storage however.&lt;/p&gt;&lt;br&gt;
&lt;p&gt;EDIT: There are also new system functions introduced: SYSDATETIME(), SYSUTCDATETIME(). Both return system time AS DATETIME2. And also SYSDATETIMEOFFSET() which returns system time as DATETIMEOFFSET.&lt;/p&gt;&lt;br&gt;
&lt;p&gt;HTH&lt;/p&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3426.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anatoly Lubarsky</dc:creator><title>T-SQL: LIKE Operator and Wildcard Characters</title><link>http://blogs.x2line.com/al/archive/2008/05/08/3420.aspx</link><pubDate>Thu, 08 May 2008 02:37:00 GMT</pubDate><guid>http://blogs.x2line.com/al/archive/2008/05/08/3420.aspx</guid><wfw:comment>http://blogs.x2line.com/al/comments/3420.aspx</wfw:comment><comments>http://blogs.x2line.com/al/archive/2008/05/08/3420.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.x2line.com/al/comments/commentRss/3420.aspx</wfw:commentRss><trackback:ping>http://blogs.x2line.com/al/services/trackbacks/3420.aspx</trackback:ping><description>&lt;p&gt;An interesting issue I came into recently. Suppose you have a search procedure - which consists of some SELECT query which gets a query phrase as a parameter and searches through a table column using LIKE.&lt;/p&gt;&lt;br&gt;
&lt;p&gt;The most common pattern is to add % at the beginning and the end of the search parameter so the query looks like so:&lt;/p&gt;&lt;br&gt;
&lt;pre&gt;WHERE Col LIKE '%' + @param + '%'
&lt;/pre&gt;&lt;br&gt;
&lt;p&gt;Or you may perform concatenation before running the query as well :) However need to take into account the following. The search parameter which usually comes down to the procedure from the application user interface can contain T-SQL reserved wildcard characters such as =&amp;gt; % [ ] _ etc. Such input will cause the query to return wrong results.&lt;/p&gt;&lt;br&gt;
&lt;p&gt;Therefore it is useful to remember to filter out or replace these characters so MSSQL will consider these characters literals. For example if we have rectangular braces =&amp;gt; [], need to replace the opening brace =&amp;gt; [ with the sequence =&amp;gt; [[] before running the query.&lt;/p&gt;&lt;img src ="http://blogs.x2line.com/al/aggbug/3420.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>