<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Jeff Smith Blog</title>
    <link>https://weblogs.sqlteam.com/jeffs/</link>
    <description>Recent content on Jeff Smith Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <managingEditor>nospam@nospam.xyzasdf (Jeff Smith)</managingEditor>
    <webMaster>nospam@nospam.xyzasdf (Jeff Smith)</webMaster>
    <copyright>Copyright &amp;copy; 2018 - Jeff Smith</copyright>
    <lastBuildDate>Fri, 11 May 2012 10:10:51 -0500</lastBuildDate>
    
	<atom:link href="https://weblogs.sqlteam.com/jeffs/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Why to avoid SELECT * from tables in your Views</title>
      <link>https://weblogs.sqlteam.com/jeffs/2012/05/11/why-to-avoid-select-from-tables-in-your-views/</link>
      <pubDate>Fri, 11 May 2012 10:10:51 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2012/05/11/why-to-avoid-select-from-tables-in-your-views/</guid>
      <description>-- clean up any messes left over from before: if OBJECT_ID(&amp;#39;AllTeams&amp;#39;) is not null drop view AllTeams go
if OBJECT_ID(&amp;#39;Teams&amp;#39;) is not null drop table Teams go
-- sample table: create table Teams ( id int primary key, City varchar(20), TeamName varchar(20) )</description>
    </item>
    
    <item>
      <title>How to calculate Median in SQL Server</title>
      <link>https://weblogs.sqlteam.com/jeffs/2010/08/30/sql-server-calculate-median/</link>
      <pubDate>Mon, 30 Aug 2010 07:32:11 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2010/08/30/sql-server-calculate-median/</guid>
      <description>Nothing earth-shattering here, I was just helping out a colleague with this so I thought I&#39;d post up the example I gave him.  -- sample table:create table People(Person varchar(1) primary key,City varchar(10),Age int)go-- with some sample data: insert into People select &amp;#39;A&amp;#39;,&amp;#39;Boston&amp;#39;,23 union all -- odd #select &amp;#39;B&amp;#39;,&amp;#39;Boston&amp;#39;,43 union allselect &amp;#39;C&amp;#39;,&amp;#39;Boston&amp;#39;,29 union allselect &amp;#39;D&amp;#39;,&amp;#39;Chicago&amp;#39;,15 union all -- single #select &amp;#39;E&amp;#39;,&amp;#39;NY&amp;#39;,12 union all -- even #select &amp;#39;F&amp;#39;,&amp;#39;NY&amp;#39;,55 union allselect &amp;#39;G&amp;#39;,&amp;#39;NY&amp;#39;,57 union allselect &amp;#39;H&amp;#39;,&amp;#39;NY&amp;#39;,61go-- here&amp;#39;s our query, showing median age per city: select city,AVG(age) as MedianAgefrom (select City, Person, Age, ROW_NUMBER() over (partition by City order by Age ASC) as AgeRank,COUNT(*) over (partition by City) as CityCountfromPeople) xwherex.</description>
    </item>
    
    <item>
      <title>Is it just me ...</title>
      <link>https://weblogs.sqlteam.com/jeffs/2009/10/27/61031/</link>
      <pubDate>Tue, 27 Oct 2009 12:50:54 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2009/10/27/61031/</guid>
      <description>&amp;hellip; or is about time I got back to some blogging?
Legacy CommentsIbleif 2009-10-27re: Is it just me ... It&#39;s not just you.</description>
    </item>
    
    <item>
      <title>The Mailbag: More on Ordering by Distinct Values ...</title>
      <link>https://weblogs.sqlteam.com/jeffs/2008/12/23/60803/</link>
      <pubDate>Tue, 23 Dec 2008 09:25:35 -0600</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2008/12/23/60803/</guid>
      <description>I promise to get back to writing articles on a more regular basis soon, but in the meantime, here&#39;s a comment from Nathan A. on using DISTINCT and ORDER BY:</description>
    </item>
    
    <item>
      <title>Processing an OLAP cube with a T-SQL Stored Procedure</title>
      <link>https://weblogs.sqlteam.com/jeffs/2008/10/27/process-olap-cube-with-t-sql/</link>
      <pubDate>Mon, 27 Oct 2008 15:26:05 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2008/10/27/process-olap-cube-with-t-sql/</guid>
      <description>Here&#39;s a simple SQL Server stored procedure that you can call to process an OLAP cube using T-SQL. The parameters should be self-explanatory. To me, this is a little easier and more flexible than processing using DTS packages.</description>
    </item>
    
    <item>
      <title>I&amp;#39;m back ... with some news!</title>
      <link>https://weblogs.sqlteam.com/jeffs/2008/10/16/60734/</link>
      <pubDate>Thu, 16 Oct 2008 16:04:35 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2008/10/16/60734/</guid>
      <description>I apologize for not posting any new content in quite some time, but now I am back and will soon start posting on a (hopefully!) regular basis once again.  The reason for my hiatus was a pretty good one, though: I recently became a father with the birth of my son Benjamin on October 2, 2008!</description>
    </item>
    
    <item>
      <title>Why Single-Column Primary/Foreign Keys Can&amp;#39;t Always Accurately Model/Constrain Your Data</title>
      <link>https://weblogs.sqlteam.com/jeffs/2008/08/13/examining-database-primary-keys/</link>
      <pubDate>Wed, 13 Aug 2008 11:06:48 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2008/08/13/examining-database-primary-keys/</guid>
      <description>A Simple Single-Child Model  Consider the following logical data model:
 There are multiple Companies Each Company has many Projects Each Project has many Tasks Each Task has a Status, selected from a global list of pre-defined Statuses.</description>
    </item>
    
    <item>
      <title>SQL Server 2005 Foreign Key Constraints: SET NULL and SET DEFAULT</title>
      <link>https://weblogs.sqlteam.com/jeffs/2008/08/13/sql-server-set-null-set-default-foreign-key-constraints/</link>
      <pubDate>Wed, 13 Aug 2008 09:56:49 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2008/08/13/sql-server-set-null-set-default-foreign-key-constraints/</guid>
      <description>Most people know about cascading updates and deletes, but did you know there are two other foreign key constraint options you can use to maintain referential integrity?  Read all about them in my latest article over at SQLTeam.</description>
    </item>
    
    <item>
      <title>Database Column Names != Report Headings</title>
      <link>https://weblogs.sqlteam.com/jeffs/2008/08/06/60669/</link>
      <pubDate>Wed, 06 Aug 2008 11:43:26 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2008/08/06/60669/</guid>
      <description>Always remember that the column names returned in a result set do not have to be the same as what you eventually output at your presentation layer.   For example, suppose you have stored procedure that accepts a @CurrentYear parameter and returns a sales variance between the current year and the previous year for each customer.</description>
    </item>
    
    <item>
      <title>How To Calculate the Number of Week Days Between two Dates</title>
      <link>https://weblogs.sqlteam.com/jeffs/2008/07/31/week-days-between-two-dates/</link>
      <pubDate>Thu, 31 Jul 2008 12:39:43 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2008/07/31/week-days-between-two-dates/</guid>
      <description>If the start date and end date are both week days, then the total number of week days in between is simply: 
(total difference in days) - (total difference in weeks) * 2   or DateDiff(dd, @start, @end) - DateDiff(ww, @start, @end)*2   .</description>
    </item>
    
    <item>
      <title>Convert input explicitly at your client; don&amp;#39;t rely on the database to &amp;#34;figure it out&amp;#34;</title>
      <link>https://weblogs.sqlteam.com/jeffs/2008/07/24/60657/</link>
      <pubDate>Thu, 24 Jul 2008 09:12:33 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2008/07/24/60657/</guid>
      <description>A common mistake beginners make when working with SQL is trying to format their output at the database layer, as opposed to simply doing this at the presentation layer (i.e., client application, reporting tool, web page, etc).</description>
    </item>
    
    <item>
      <title>The MailBag --- Super-Sized Edition!  String Parsing, Crosstabs, SQL Injection, and more.</title>
      <link>https://weblogs.sqlteam.com/jeffs/2008/07/16/60652/</link>
      <pubDate>Wed, 16 Jul 2008 16:32:51 -0500</pubDate>
      <author>nospam@nospam.xyzasdf (Jeff Smith)</author>
      <guid>https://weblogs.sqlteam.com/jeffs/2008/07/16/60652/</guid>
      <description>OK, boys and girls, it&#39;s time for the mailbag! There&#39;s lots of stuff to cover, so let&#39;s get to it!  &amp;mdash;  Greg E writes: 
Hello Jeff,I just found your blog and wanted to know if you could point me in the right direction or possibly toss me a solution.</description>
    </item>
    
  </channel>
</rss>