<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/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>SQL 2005</title>
        <link>http://geekswithblogs.net/jonasb/category/4450.aspx</link>
        <description>Posts about SQL 2005</description>
        <language>en-US</language>
        <copyright>Jonas Bush</copyright>
        <managingEditor>jonasbush@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Images being requested twice from the server</title>
            <link>http://geekswithblogs.net/jonasb/archive/2009/07/13/133462.aspx</link>
            <description>&lt;p&gt;&lt;font size="2" face="Verdana"&gt;*taptaptap* Is this thing on?&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt; I ran into an interesting bug recently, where you would get 2 identical requests to the page you were visiting. I wasn't sure where this was coming from, so I poked around a bit. It turns out that having an &lt;font face="Courier New"&gt;&amp;lt;img /&amp;gt;&lt;/font&gt; tag on a page with an empty src attribute (like so: &lt;font face="Courier New"&gt;&amp;lt;img src="" /&amp;gt;)&lt;/font&gt; causes that image tag to point to the containing page, causing the entire page to get requested again (causing any server-side code you may have to get executed again), but the response just gets thrown away, since the img tag is only expecting an image back from the server, not an HTML document. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;The way around this is to remove the src attribute altogether, and you can still set the image source through javascript.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=133462"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=133462" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/jonasb/aggbug/133462.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jonas Bush</dc:creator>
            <guid>http://geekswithblogs.net/jonasb/archive/2009/07/13/133462.aspx</guid>
            <pubDate>Mon, 13 Jul 2009 16:55:59 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/jonasb/comments/133462.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/jonasb/archive/2009/07/13/133462.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/jonasb/comments/commentRss/133462.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/jonasb/services/trackbacks/133462.aspx</trackback:ping>
        </item>
        <item>
            <title>Retrieivng data from XML inside SQL</title>
            <link>http://geekswithblogs.net/jonasb/archive/2006/05/03/77138.aspx</link>
            <description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Recently I had to retrieve some data from SQL that was tucked away inside XML. We have a &amp;#8220;Settings&amp;#8221; class inside our application that is a bunch of public properties, which we then serialize to XML to store inside the DB. This lets us easily add/remove fields to store without having to modify the database.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This can be a problem if you need to access those one of those field values from within SQL, but SQL 2005 provides some methods to do this (note that your data column must be the xml data type, I haven't found a way to get this to work by casting an ntext field to xml):&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Providing your class looks like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;[XmlSerializable]&lt;BR&gt;public class GlobalSettings&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; [XmlElement]&lt;BR&gt;&amp;nbsp; public int SomeValue;&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Then when serialized, your XML will look similar to this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;lt;GlobalSettings&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;SomeValue&amp;gt;5&amp;lt;/SomeValue&amp;gt;&lt;BR&gt;&amp;lt;/GlobalSettings&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT face=Verdana&gt;In SQL Management studio, you can write this (assuming GlobalSettings is the table and GlobalSettingsXML is the column where this data is stored):&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;SELECT GlobalSettingsXML.query('(/GlobalSettings/SomeValue)') FROM GlobalSettings&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This will return:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;lt;SomeValue&amp;gt;5&amp;lt;/SomeValue&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Which may not be as useful as we want. :) To get the actual value (5) from this, we need to use the value() function:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;SELECT GlobalSettingsXML.value('(/GlobalSettings/SomeValue)[1]', 'int') FROM GlobalSettings&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This will give us '5', cast to an int. Per the MSDN helps on value(), the [1] is required after your xpath expression because the expression is supposed to return a singleton. I'm not quite sure what that means or how the [1] denotes it, but it works (if you know, by all means tell me!).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Hopefully this will be of use to you.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=77138"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=77138" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/jonasb/aggbug/77138.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jonas Bush</dc:creator>
            <guid>http://geekswithblogs.net/jonasb/archive/2006/05/03/77138.aspx</guid>
            <pubDate>Wed, 03 May 2006 20:07:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/jonasb/comments/77138.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/jonasb/archive/2006/05/03/77138.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/jonasb/comments/commentRss/77138.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/jonasb/services/trackbacks/77138.aspx</trackback:ping>
        </item>
    </channel>
</rss>