6

When desiging a table in SQL Server Management Studio 2005, if I specify VARCHAR(10) for a column, when I tab away from the data type, SQL Server changes it to VARCHAR(50). I have to then tab back, change it back to VARCHAR(10), and it will then accept it.

I understand that there are storage and processing considerations that may make VARCHAR(10) equivalent to CHAR(10) for all intents and purposes, but is there something I'm missing? Is there enough of a reason that I'm not considering, that the default behavior of the designer is to automatically change the length of the column from what I've specified?

4
  • What version of Management studio? If 2008, you could always hit the script button and change the varchar 50 back to 10. I have never encountered this so I would assume its a bug in the version you are using.
    – Codezy
    Commented Oct 8, 2009 at 14:29
  • SSMS version 2005 - added to post. Commented Oct 8, 2009 at 14:45
  • Still a bug in SSMS 2008, as of 2011/04/28. I have "varchar(10)" columns I'm changing to "nvarchar(10)". I click the field, I add an 'n', I click away... SSMS changes it to "nvarchar(50)". In fact, I've even tried pasting the entire string "nvarchar(10)" into the data type column, and when I click away, it resets it to "nvarchar(50)". This is a HUGE BUG.
    – Triynko
    Commented Apr 28, 2011 at 18:10
  • It also changes varchar(1) columns to varchar(10). It seems to be increasing the length to the next highest step. So anything less than 10 will become 10, and anything from 10 to 49 will become 50.
    – Triynko
    Commented Apr 28, 2011 at 21:04

6 Answers 6

9

No, it's a bug in SSMS when you tab away from a field. It does get irritating.

2
  • Still a bug in SSMS 2008 as of 2011/04/28.
    – Triynko
    Commented Apr 28, 2011 at 18:11
  • Still happening to me in SSMS 17.5. Can't believe they haven't fixed this yet.
    – Dave.Gugg
    Commented Aug 14, 2018 at 19:58
4

probably it's just a bug in the designer.

2

I would strongly suggest never using the designer to create a table or change a table structure. You should write a create table or alter table statement for that and put it into source control. Then it is easier to deploy to production.

0
0

No, there's absolutely no reason for designer to change data type. And I cannot reproduce it in Management Studio 2008.

If you're so into designer, create a UDT (User-Defined Type) and use it instead of varchar(10):

create type dbo.MyChar from varchar(10) not null
4
  • I'm using SSMS 2005, so it appears that they may have changed (fixed) it in 2008. I know it was like this in 2000 as well. Commented Oct 8, 2009 at 14:30
  • Bah. Can't edit comments. I thought it was like that in SSEM 2000, but that doesn't appear to be the case. Commented Oct 8, 2009 at 14:32
  • USER Defined types should be avoided at all costs. If you ever need to change them they are aroyal pain.
    – HLGEM
    Commented Oct 8, 2009 at 20:18
  • Still a bug in SSMS 2008, as of 2011/04/28.
    – Triynko
    Commented Apr 28, 2011 at 18:09
0

I would strongly recommend switching to Toad for SQL Server to get rid of all those annoyances..

1
  • unfortunately, for most of us, in our corporate worlds, this is not an option. If it's not on the approved list, it is forbidden.
    – BBlake
    Commented Oct 8, 2009 at 15:17
0

It is a bug in ssms 2008 when you go somewhere else without clicking the data type it takes default setting as varchar(50)..so dont worry and no need to think, just handle it carefully..

Not the answer you're looking for? Browse other questions tagged or ask your own question.