views:

203

answers:

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  A: 

probably it's just a bug in the designer.

Mladen Prajdic
A: 

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
Anton Gogolev
it's a bug in 2005
BBlake
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.
Rich.Carpenter
Bah. Can't edit comments. I *thought* it was like that in SSEM 2000, but that doesn't appear to be the case.
Rich.Carpenter
USER Defined types should be avoided at all costs. If you ever need to change them they are aroyal pain.
HLGEM
+5  A: 

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

BBlake
+1, happens for me in SQL Server 2005
KM
A: 

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

ercan
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
+2  A: 

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.

HLGEM
Hear, hear! Improve your SQL coding...
gbn
A: 

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