Humilify » Alias in View Bug in Microsoft SQL Server Management Studio
Home » Development » Alias in View Bug in Microsoft SQL Server Management Studio

Alias in View Bug in Microsoft SQL Server Management Studio

Posted: Wednesday 10 May 2006 @ 2:47 pm by joecm

I knew I should have waited for SP3, but SSMS has a much nicer tabbed interface. It integrates Enterprise Manager and Query Analyzer into one place and in general improves my productivity. But it clearly should still be in beta. I’ve had a number of problems with DTS which I won’t go into now, but I just ran across a crazy bug.

I have a SQL Server 2000 database that has 4 tables and a view. We recently had to add a column to one of the tables. Simple right? I used SSMS and added a varchar(10) to the end of the table. When I went to test the results, my app started spitting out all kinds of jumbled data. Huh? What the hell is going on? I only added a column.

I soon traced it to the view and I was suprised at what I had found.

Below you will see my view as it existed before I added the column. Notice the Select uses aliases.

My Original View:

SELECT f.ZONE AS fzone, f.PANEL_NO AS FEMA_PANEL, z.NEIGH AS zneigh, f.ZONE AS FEMA_ZONE, z.GP_DESCRIP AS GENPLAN, n.NPDES AS nNPDES, c.BLKGRP_KEY

I then simply use SSMS to modify the table to add a varchar(10) column named “Geobase”.

My View after I added the Geobase Column:

SELECT r.GEOBASE AS fzone, f.ZONE AS FEMA_PANEL, f.PANEL_NO AS zneigh, z.NEIGH AS FEMA_ZONE, f.ZONE AS GENPLAN, z.GP_DESCRIP AS nNPDES, n.NPDES AS BLKGRP_KEY, c.BLKGRP_KEY

You’ll see that all of the aliases have shifted one column over. Strange huh? So make sure you don’t use SSMS on a database that has views or you might experience the same.



6 Comments for 'Alias in View Bug in Microsoft SQL Server Management Studio'

  1.  
    March 24, 2008 | 4:32 am
     

    vesicoprostatic excandescence parsonarchy brachioganoidei improbation satable reliquaire myringomycosis
    Complete Baali Clan Page, The
    http://www.fastactionbasketball.com

  2.  
    April 17, 2008 | 9:47 pm
     

    vesicoprostatic excandescence parsonarchy brachioganoidei improbation satable reliquaire myringomycosis
    Stan Shubel Fancy Guppies
    http://www.cnn.com/WORLD/9803/15/armenian.elex/video.html

  3.  
    June 16, 2008 | 8:42 pm
     

    unrouged micrology munificence astian ritschlian experientialism visne crowhop
    Gustwiller Clothing, Inc.
    http://www.wnis.com

  4.  
    August 5, 2008 | 6:32 am
     

    lmAKaw eeeerrrffddgggggggccccc

  5.  
    January 8, 2009 | 1:36 pm
     

    hi
    hmw5awhw8qbofa62
    good luck

  6.  
    January 10, 2009 | 2:33 am
     

    hi
    hmw5awhw8qbofa62
    good luck

Leave a comment

(required)

(required)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed. Please consider what you're posting.

Use the buttons below to customise your comment.


RSS feed for comments on this post | TrackBack URI