Groups | Blog | Home
all groups > sql server new users > february 2006 >

sql server new users : SQL 2000: Extra padding (whitespace) in char column...


Andrew Wilcox
2/1/2006 7:53:21 PM
Hello,

I have a suppliers table in my database, with the 'name' column defined as
char(35). My problem is that SQL seems to add padding to make it 35 chars,
for example, "Office Depot ". I have tried Googling
and looking on the SQL newsgroups to no avail. This also happens with the
'website' column defined as char(50).

This appears in both my Visual Basic .NET 2002 program and in the Enterprise
Manager.

This problem does not appear in my Customers table, which for example, has a
column 'address' defined as varchar(50).

Thank you for your help!

Andrew

Mike Hodgson
2/2/2006 12:00:00 AM
That's what a char() column is - a fixed width character column. If you
want a variable width character column use the varchar() datatype instead.

To find out more info on char() vs varchar() see BOL (eg.
http://msdn.microsoft.com/library/en-us/tsqlref/ts_ca-co_7tpu.asp)

--
*mike hodgson*
http://sqlnerd.blogspot.com



[quoted text, click to view]
AddThis Social Bookmark Button