<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tags 'SQL Server 2008', 'BLOB', 'SQL 2008', 'SQL Server', 'sample database', and 'programming'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=SQL+Server+2008,BLOB,SQL+2008,SQL+Server,sample+database,programming&amp;orTags=0</link><description>Search results matching tags 'SQL Server 2008', 'BLOB', 'SQL 2008', 'SQL Server', 'sample database', and 'programming'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>T-SQL Tuesday #006: Tiger/Line Spatial Data</title><link>http://sqlblog.com/blogs/michael_coles/archive/2010/05/11/t-sql-tuesday-006-tiger-line-spatial-data.aspx</link><pubDate>Tue, 11 May 2010 23:11:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:25058</guid><dc:creator>Mike C</dc:creator><description>&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;This month’s &lt;A href="http://sqlblog.com/blogs/adam_machanic/archive/2009/11/30/invitation-to-participate-in-t-sql-tuesday-001-date-time-tricks.aspx"&gt;T-SQL Tuesday&lt;/A&gt; post is about LOB data &lt;A href="http://sqlblog.com/blogs/michael_coles/archive/2010/05/03/t-sql-tuesday-006-what-about-blob.aspx"&gt;http://sqlblog.com/blogs/michael_coles/archive/2010/05/03/t-sql-tuesday-006-what-about-blob.aspx&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;For this one I decided to post a sample Tiger/Line SQL database I use all the time in live demos. For those who aren't familiar with it, Tiger/Line data is a dataset published by the &lt;A title="...and still counting!" href="http://www.census.gov/geo/www/tiger/tgrshp2009/tgrshp2009.html"&gt;U.S. Census Bureau&lt;/A&gt;. Tiger/Line has a lot of nice detailed geospatial data down to a very detailed level.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;It actually goes from the U.S. state level all the way down to street, feature and landmark&amp;nbsp;level. Tiger/Line data is very complete and detailed--but the best part is it's FREE.&amp;nbsp; There are lots of applications for Tiger/Line, like national [U.S.] and local mapping and&amp;nbsp;geocoding applications &lt;EM&gt;[applications that convert street addresses to (latitude, longitude) coordinates]&lt;/EM&gt;.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;All this great data is distributed in the form of a ton of ESRI shapefiles.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;A shapefile is basically a file format that contains shape objects like points, lines and polygons. &lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;SQL Server doesn’t natively understand ESRI shapefiles, but it also stores geospatial objects like lines, points and polygons.&amp;nbsp; There some handy utilities out there for loading these files into SQL Server. &lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;Morten Nielsen has a great utility for loading shapefiles into Geometry and Geography data types at &lt;A href="http://www.sharpgis.net/page/Shape2SQL.aspx"&gt;http://www.sharpgis.net/page/Shape2SQL.aspx&lt;/A&gt;.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; Because of the volume of data involved in this project (I loaded hundreds of shapefiles) &lt;/SPAN&gt;I decided to&amp;nbsp;roll my own small set of SSIS custom components that read ESRI shapefiles and convert them to SQL Server spatial data types &lt;EM&gt;[keep an eye out -- these components are scheduled to be published with source code by SQL Server Standard magazine in the near future]&lt;/EM&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The sample database can be downloaded from &lt;A href="http://www.sqlkings.com/downloads/Tiger_Sample.zip"&gt;http://www.sqlkings.com/downloads/Tiger_Sample.zip&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Download the ZIP file from &lt;A href="http://www.sqlkings.com/downloads/Tiger_Sample.zip"&gt;http://www.sqlkings.com/downloads/Tiger_Sample.zip&lt;/A&gt;.&lt;/FONT&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Extract the database backup file and restore it to a SQL Server 2008 instance.&lt;/FONT&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In the future I’ll be sharing some code samples on the blog to demonstrate Tiger/Line data (as well as spatial data from other sources) based on this database.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Here are a couple of quick queries you can run against this sample database to view the spatial data in SSMS 2008.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:gray;"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; Tiger&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;State&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;IMG style="WIDTH:690px;HEIGHT:328px;" title="US of A" alt="US of A" src="http://www.sqlkings.com/blog_images/state.png" width=690 height=328&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; c&lt;SPAN style="COLOR:gray;"&gt;.*&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; Tiger&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;State&lt;/SPAN&gt; s&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;INNER&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:gray;"&gt;JOIN&lt;/SPAN&gt; Tiger&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;County c&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;ON&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; s&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;STATEFP &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; c&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;STATEFP&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;WHERE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; s&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;STUSPS &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;'TX'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&lt;IMG style="WIDTH:690px;HEIGHT:329px;" title="All my ex's live in Texas" alt="All my ex's live in Texas" src="http://www.sqlkings.com/blog_images/county.png" width=690 height=329&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:gray;"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; Tiger&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;ZCTA z&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;WHERE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; z&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;ZCTA5CE00 &lt;SPAN style="COLOR:gray;"&gt;LIKE&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;'0[7-8]%'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;IMG style="WIDTH:687px;HEIGHT:332px;" title=Jersey--Howyadoin? alt=Jersey--Howyadoin? src="http://www.sqlkings.com/blog_images/zcta.png" width=542 height=268&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;This last one works because all of the ZIP Code tabulation areas for the state of New Jersey start with '07' and '08'.&amp;nbsp; There are similar relationships between other ZCTA prefixes&amp;nbsp;and their states.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Next time we'll look at using SQL Server-based spatial data with online mapping programs like Bing maps.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&amp;nbsp;&lt;/P&gt;&lt;o:p&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;*For more information about Tiger/Line data visit&amp;nbsp;&lt;A href="http://www.census.gov/geo/www/tiger/tgrshp2009/tgrshp2009.html"&gt;http://www.census.gov/geo/www/tiger/tgrshp2009/tgrshp2009.html&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;/o:p&gt;</description></item></channel></rss>