Plip's Weblog

Phil Winstanley - British Microsoft ASP.NET MVP & ASP Insider.

SQL Server 2005 doesn't like numbers less than 50

I've been creating a database for a client and it requires the creation of some fields which are of type varchar(10). Nothing weird there I'm sure you'll agree.

In creating these tables I'm using SQL Server Management Studio and I've found a little bug.

If you create a column, enter a name, press tab (so you're in the Data Type), paste "varchar(10)" into the column, move off and it changes to "varchar(50)", lord knows why.

Go in and manually change the value to "10" and it works fine.

Silly thing. :-)

Edit: Welcome from Dr Dobbs - I hope you're not a Thomas. 

Comments

Thomas said:

Seems strange that you want to make headlines with a insignifikant bug that you already found a workaround for, why don't you publish something that you found cool about Microsof SQL Server 2005? Start promoting the product if you like it and want it to gain market and acceptance, or get another job where they use another product.

# August 2, 2006 7:10 PM

Steve said:

Yes, why don't we just ignore every bug Microsoft has ever written? Let's all go back to running Access 95 on Windows ME!!

# August 2, 2006 7:17 PM

Richard Anderson said:

Thomas,  The only way to get bugs fixed are to report them and to bring attention to them.  This may not seem like a big problem and there is a work around. But if you are creating a table where the majority of the varchars are less then 50, it would would sure be a nuisance to have to change all of them when all that had to happen was a Microsoft coder testing and coding the funcitonality correctly.  We pay good money for software and for some reason, it appearantly is perfectly acceptable to ship crap and then not do anything about it.  You wouldn't accept this from your TV, car, or other appliance manufacturer. Why do we accept it from software?

# August 2, 2006 7:29 PM

EduPer said:

Some of us might thing that it makes perfect sense to use varchars greater then 50, because varchar exists mainly to save storage space, loosing performance in the process. Being storage space cheap as it is now, why use varchar smaller than 50? That's probably what managment studio is trying to tell us.

EduPer

# August 2, 2006 7:43 PM

dterrie said:

Yes, we get the same behavior on our side of the pond. SQL Server is a great product overall, but there are still annoyances it would be nice to have cleaned up over time. For example, running an SSIS job via SQL Server Agent should be a no-brainer, but a screwed up security implementation makes it extremely difficult. Ditto for the genius who removed built-in importing of dBase files.

# August 2, 2006 7:43 PM

Aaron Edwards said:

Yeah, and stop being an instigator too!

# August 2, 2006 7:43 PM

Jonathan said:

Thomas, if you are ever looking for a job as a DBA, please reference this post. It is good information for a prospective employer to know. I know that I would want this information so I would not waste my time interviewing.

# August 2, 2006 8:08 PM

Dave Diehl said:

"make headlines"?  Hardly.  This isn't exactly the Times.

But...it's important for those who've become accustomed to using tools like Studio or Enterprise Manager to save time.  You just expect the simple things to work.  

And...yes...I replicated it as well.  

# August 2, 2006 8:23 PM

Bob said:

WTF! I can't believe this is a headline. A waste of my time. I agree with the first poster, Thomas. Publish something worth reading. Be greatful SSMS does everything it does do. Can you image keeping up with and maintaining SQL scripts to do all the things you take for granted.

# August 2, 2006 9:05 PM

Bob said:

By the way, I linked to this blog from a ddj email headlining this blog. Nothing personal against Plip. http://www.ddj.com/blog/databaseblog/archives/2006/07/strange_error_i.html

# August 2, 2006 9:13 PM

mostof said:

A bug is a bug, no matter how small it is.  SQL Server is quite expensive and it's quite shameful to find a bug like this (although it's not a big deal and a workaround exists).  It would be more efficient though to bring M$'s attention to it to provide a fix in a patch.

# August 2, 2006 9:59 PM

Erik Eckhardt said:

Thomas: You are a ding dong. And yes, that is the correct technical term in this situation.

EduPer: Management studio isn't "trying to tell us" anything. Have you considered that someone may have good reasons for choosing a small maximum number of characters in a field?

Bob: If your time was actually so valuable that reading a short, amusing article was truly "a waste," then you wouldn't waste any MORE time posting, now would you? Think about it. Plip complains about something that wastes his time. So you complain that he's complaining. I, on the other hand, thank you for being so easy to make fun of.

Stupid little glitches like this interfere with efficient thought and execution of a plan. They're more expensive than just the pure calculated time difference between glitchy and proper function.

# August 2, 2006 10:22 PM

Millsy said:

My god. You'd swear that posting this has killed the unborn children of some of you guys. I hope no one ever complains about the weather around you guys.

# August 2, 2006 10:37 PM

dave dolan said:

Haha, is that someone actually complaining about a bug that is being reported?  If I wrote a newsletter on a slow day you'd be seeing "Dilbert" highlights. I think at least this is on topic. Geez.  People lighten up, and  don't be caught offguard by the flaky behavior.

# August 2, 2006 11:13 PM

Suman said:

You post don’t qualify for headline. Sheer wastage of time.

# August 3, 2006 12:06 AM

3rx said:

Shut up you stupid lot!  Let the man say his say on varchar(10) flipping to varchar(50), give him a break!  Gzzz!  Touchy bastards!

# August 3, 2006 12:31 AM

Plip's Weblog said:

I recently blogged about a small but frustrating bug in SQL Server relating to creating new columns of

# August 3, 2006 1:52 AM

Guus said:

Previous version of MS SQL has the same bug.

# August 3, 2006 3:27 AM

Me said:

Any complaintants about bugs in todays db software should have been around 20 years ago when really the only pc record manager that was available was the btrieve record manager, be thankful and stop bitching about something so insignificant as varchar(50).  Those of you who even know what im talking about will understand. Those of you dont, do some research.

# August 3, 2006 3:55 AM

Deepak Kumar said:

Hi: This bug was first reported to MS on April 18, 2006 by Skiwi.

Check details from:

-------------------

http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=127135

Thanks,

Deepak Kumar

http://forum.sqlknowledge.com

# August 3, 2006 4:54 AM

Steve Nixey said:

If Microsoft have allowed such a simple bug to get into a release version of a product what else can we exepect, what lays beneath?.

Microsoft produces some of the best software around and without them (and their bugs) we would have less money in our bank accounts and less to complain about! so be greatful.

# August 3, 2006 5:08 AM

JonR said:

if programmers are rock stars, and IT pros are disc jockeys - what are DBAs...? answers on a postcard.

# August 3, 2006 5:12 AM

Man50n said:

You all bloody idiots!

# August 3, 2006 5:31 AM

Gene said:

I think what you are seeing is just SQLMS setting the DEFAULT length for varchar. Yes, it set this default in SQL 2000 EM also, as well as setting default lengths in MS Access also.

# August 3, 2006 8:01 AM

jwgreg said:

Wow, I have never been a blogger.  This issue caught my eye because I too have experienced it.

What is everybody getting so worked up about.  I am sure it will be fixed in the next SP.  Is this what blogging is all about... what a waste of time.

# August 3, 2006 8:13 AM

Someone who is better than you in every way said:

Has it not occurred to anybody else that the e-mail newsletter is just auto-generated and quotes whatever happens to be the most recent post on Doug's blog? OK, why Doug saw fit to link this fairly bland post is questionable, but it's hardly Plip's fault. If I only posted about issues of great pitch and moment on my blog, it'd be practically empty. Oh, wait, it is.

# August 3, 2006 9:14 AM

Idiots said:

You all are idiots.  What is wrong with posting a bug that is found.  Lighten up losers.

# August 3, 2006 10:03 AM

CodeSniper said:

Plip, posting bugs = good.

Others, complaining about people who post bugs = bad.  

Ultimately, I'm sure MS appreciates such info so they can improve product quality.  

At least MS isnt like Oracle who puts out a piece of crap like SqlPlus and says "we're done!" for the next 10 years.  :)

Its all good...

# August 3, 2006 10:33 AM

Gbenga said:

I'm not swearing here... Every software vendor appreciates bug reports of any sort, but in general I think Oracle products are alot more stable than MS's. Interestingly, I use more of MS products because the do's are more than the don'ts...for me, software is an expression of trust. Do you trust me???

# August 3, 2006 12:15 PM

Cykophysh said:

The reason it wise to report all sorts of bugs even if the seem to be insignificant, is because even the smallest bug can cause complete distrust in a product in general. I know I have been writing software for many years, and it doesn't matter how good your product is, if it does the small things wrong, people immediately think it will do the big things wrong too.

# August 3, 2006 12:34 PM

Fransisco said:

"It's not a bug, it's an unexpected feature" - Source Unknown

Like trying to open entire 20 Million rows table.

# August 3, 2006 2:40 PM

Gabriel Lozano-Morán said:

@Gbenga:

Oracle product a lot more stable than MS's? Now don't let me get started on the difference between empty strings and null values in the Oracle DBMS

# August 3, 2006 9:02 PM

CYkophysh said:

what about having to hold donw the CTRL key when opening up an EXCEL file from a webpage. I neat little feature there!!

# August 4, 2006 7:07 AM

Gbenga said:

@Gabriel Lozano-Moran:

The difference in implementation issues btw Oracle and MS DBMSs is not the point, but simply for a product to say "Yea" and you find it to be so 99% of the time. No hard feelings, but Oracle DBMSs are still the preferred.

# August 4, 2006 10:01 AM

Gabriel Lozano-Morán said:

Sounds to mee like you are a convinced Oracle guy. Have you even every tried the deployment of SQL Server 2005 to conclude that Oracle DBMS is way more stable than SQL Server 2005? Ever considered that if there are stability issues that they had nothing to do with SQL Server but the platform it runs on or the hardware used?

# August 4, 2006 8:00 PM

Aaron Seet (icelava) said:

I also experienced this annoyance when working on SSIS project in June. The interesting thing is it only reverts from (10) to (50). If it is (9) or (11) it won't revert.

# August 7, 2006 10:31 AM

Andrew said:

While we are bitching about SQL Studio, it should be noted that, after adding a field to a view and placing a sort on the field, the field does not like to be removed from the output. You must remove it from output first and then apply the order/sort.

Speaking of which...

Why does the output shown in the studio ALWAYS obey the Order By clause, while output from the view requested in a query does not? Why bother using/adding/including sort behavior in the IDE if it's not enforced by the server? Why two different responses, one for the IDE and another for the query?

Why was view data sorting an "undocumented feature" that was reliable in SQL 2K but not in 2005?

# August 9, 2006 4:37 PM

I'm not a Thomas - I'm The Thomas said:

Plip - sorry for being so rude, asking you get get another job an so on, that was not fair - my apology. I think that SQL Server likes all kinds of numbers - and it is not strange that the paste function does not work in some cases, that is all - preceding my initial post, I had a bad evening because of issues at work. Now I have a new job that pays more, shorter work days, so I don't have to rave about small stuff anymore :-)

Thomas - The Danish Dynamo

# August 9, 2006 4:41 PM

TwoShay said:

That is a pain...I've never had it happen, but I'm really old-school...I often build tables in SQL rather than using the UI's anyway.

Whoever says that storage is so cheap we don't need to worry about an extra few bytes may never have managed the table space, index space, and index structures for several billion rows.  

Every byte is sacred

 every byte is great

if a byte is wasted

 the good DBA's irate...

# August 9, 2006 4:42 PM

Mison Rubrowes said:

I am so grateful to the first poster for pointing out the bug. I was literally just about to create a varchar(49) to hold a list of short but amusing anecdotes on the history of the mouse trap. I'll now think long and hard about the possibility of migrating to the Oracle platform before completing this task.

# August 10, 2006 4:20 AM

awe said:

I haven't tried this db tool, but I know from experience with graphic web design tools (Read: dotNet Web Matrix), that when things happen automatic, it's good if it works, but when it don't, it's better to use notepad.

# August 10, 2006 4:31 AM

Rodney Joyce said:

Beam me up Scotty, there's no intelligent life down here...

# August 10, 2006 8:15 AM

The Thomas said:

I agree Rodney - ~70% of the posters do not know what the bug is, ~90% does not know what it means to have a varchar(50) vs varchar(10), I think the anti Thomas posters and Plip are typical Dr. Dobb readers that are generalists, and not Windows specialists. People that makes a big deal out of nothing. The same people we struggle with on a daily basis, opportunists that have little success as professionals, but make a living by making a big deal out of nothing.

# August 12, 2006 8:48 AM

Abdul Jakul said:

thomas is a gay dont hire him as your developer his product is full of small bugs and really nasty huge bugs

# August 16, 2006 8:57 AM

Johnny Come Lately, MCDBA said:

Seriously now. How old must the previous poster be?

I wonder how many posters have actually written software. Of those who have actually written and PUBLISHED software, how many achieved ZERO faults?

Maybe it's a bug, or maybe just a design flaw. A bug is where software does not work/behave as expected. The design calls for setting default values when a datatype is selected - in this case, 50 for VARCHAR and nVARCHAR.

Even if you're limiting the maximum size of the varchar, you should still be utilizing constraints to give you proper error handling (although your UI should check for valid input first).

Whether or not this annoyance/bug/whatever merits "headlines" is subjective to the reader.  Personally, it isn't something I think I've ever consciously encountered in all the years I've been working w/ SQL Server (all the way back to 6.5).

# August 31, 2006 10:49 AM

Ian Nelson said:

I've just encountered this bug when trying to add several nvarchar(10) columns to a table - it's really irksome.  I know it's only a minor thing, but it would have been nice to have this fixed in one of the last two SQL Server 2005 service packs!

# May 30, 2007 8:42 AM

Microsoft » Blog Archives » SQL Server Installation/Upgrade FAQ said:

Pingback from  Microsoft  » Blog Archives   » SQL Server Installation/Upgrade FAQ

# June 14, 2007 7:11 PM

Microsoft » Blog Archives » patch set experienced a number of bugs related said:

Pingback from  Microsoft  » Blog Archives   » patch set experienced a number of bugs related

# July 18, 2007 1:18 PM

Microsoft » Blog Archives » FAQ: SQL 7.0 Service Packs said:

Pingback from  Microsoft  » Blog Archives   » FAQ: SQL 7.0 Service Packs

# August 2, 2007 11:05 PM

Microsoft » Blog Archives » Monitoring - SQL Server 2005 Dynamic Views and said:

Pingback from  Microsoft  » Blog Archives   » Monitoring - SQL Server 2005 Dynamic Views and

# August 10, 2007 3:53 AM

D.S. said:

I was victimized by this bug today. The bug is subtle so it's likely that you're gonna miss when SQL Server doesn't do what you tell it to do. It's just one of those annoying bugs in SQL Server 2005. Why didn't they correct this in SP1?

# August 23, 2007 5:40 AM

Ian said:

God, there are way too many people in this industry without basic database theory understanding:

1. Empty string is NOT the same thing as NULL just because you want it to be (@Gabriel Lozano-Morán).   And just because Microsoft have chosen to implement it that way doesnt make it right either.   I hope you dont do reporting because often people that dont understand this lose data because of poor NULL handling.

2. Varchar is NOT char because the it does NOT reserve space for the field.   Varchars only use as much space as there are characters so the only problem with having varchar(50) rather than varchar(10) is that no exception is raised if you try to put in more than 10 characters - which may cause issues downstream (e.g. if used by a form that only allows for 10 characters.  

# January 23, 2008 6:47 PM

microsof sql server said:

Pingback from  microsof sql server

# April 14, 2008 1:39 AM

Aaron Clausen said:

There are lots of niggling little bugs like this in SQL Server 2005 Management Console. Full credit for blogging about it and increasing the awareness of these bugs. Yes, one does wonder how such bugs make it into production.

I feel that very little thought about usability went into designing this application, some aspects of it are simply terrible to use, although I do agree that overall its an excellent product.

If you whingers don't like reading about these bug reports on this blog, then don't read it - simple!

# September 24, 2008 9:48 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)