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. 

Published Sunday, July 30, 2006 11:12 PM by Plip

Comments

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 7:10 PM by Thomas

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 7:17 PM by Steve

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!!

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 7:29 PM by Richard Anderson

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?

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 7:43 PM by EduPer

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

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 7:43 PM by dterrie

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 7:43 PM by Aaron Edwards

Yeah, and stop being an instigator too!

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 8:08 PM by Jonathan

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 8:23 PM by Dave Diehl

"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.  

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 9:05 PM by Bob

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 9:13 PM by Bob

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

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 9:59 PM by mostof

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 10:22 PM by Erik Eckhardt

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 10:37 PM by Millsy

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 02, 2006 11:13 PM by dave dolan

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 12:06 AM by Suman

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

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 12:31 AM by 3rx

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!

# Some SQL Server DBA's are odd ...

Thursday, August 03, 2006 1:52 AM by Plip's Weblog

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

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 3:27 AM by Guus

Previous version of MS SQL has the same bug.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 3:55 AM by Me

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 4:54 AM by Deepak Kumar

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

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 5:08 AM by Steve Nixey

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 5:12 AM by JonR

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

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 5:31 AM by Man50n

You all bloody idiots!

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 8:01 AM by Gene

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 8:13 AM by jwgreg

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 9:14 AM by Someone who is better than you in every way

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 10:03 AM by Idiots

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

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 10:33 AM by CodeSniper

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...

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 12:15 PM by Gbenga

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???

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 12:34 PM by Cykophysh

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 2:40 PM by Fransisco

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

Like trying to open entire 20 Million rows table.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 03, 2006 9:02 PM by Gabriel Lozano-Morán

@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

# re: SQL Server 2005 doesn't like numbers less than 50

Friday, August 04, 2006 7:07 AM by CYkophysh

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

# re: SQL Server 2005 doesn't like numbers less than 50

Friday, August 04, 2006 10:01 AM by Gbenga

@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.

# re: SQL Server 2005 doesn't like numbers less than 50

Friday, August 04, 2006 8:00 PM by Gabriel Lozano-Morán

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?

# re: SQL Server 2005 doesn't like numbers less than 50

Monday, August 07, 2006 10:31 AM by Aaron Seet (icelava)

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 09, 2006 4:37 PM by Andrew

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?

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 09, 2006 4:41 PM by I'm not a Thomas - I'm The Thomas

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

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 09, 2006 4:42 PM by TwoShay

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...

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 10, 2006 4:20 AM by Mison Rubrowes

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 10, 2006 4:31 AM by awe

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 10, 2006 8:15 AM by Rodney Joyce

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

# re: SQL Server 2005 doesn't like numbers less than 50

Saturday, August 12, 2006 8:48 AM by The Thomas

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.

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, August 16, 2006 8:57 AM by Abdul Jakul

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

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 31, 2006 10:49 AM by Johnny Come Lately, MCDBA

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).

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, May 30, 2007 8:42 AM by Ian Nelson

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!

# Microsoft » Blog Archives » SQL Server Installation/Upgrade FAQ

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

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

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

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

Thursday, August 02, 2007 11:05 PM by Microsoft » Blog Archives » FAQ: SQL 7.0 Service Packs

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

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

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

# re: SQL Server 2005 doesn't like numbers less than 50

Thursday, August 23, 2007 5:40 AM by D.S.

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?

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, January 23, 2008 6:47 PM by Ian

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.  

# microsof sql server

Monday, April 14, 2008 1:39 AM by microsof sql server

Pingback from  microsof sql server

# re: SQL Server 2005 doesn't like numbers less than 50

Wednesday, September 24, 2008 9:48 PM by Aaron Clausen

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!

Leave a Comment

(required) 
(required) 
(optional)
(required)