Monday, March 26, 2012

Import from MySQL db adds padding in CHAR (Text) fields

I'm moving a small application from a MySQL db to MSSQL2K and using the Import feature of SQL2K. The db in question is simple, only three tables, mostly text (CHAR) fields. The problem is that when I examine the field contents I find that the unused cha
racter positions within the fields have been padded with trailing spaces. (Example: original 10 char field containing "ABC" now contains "ABC ". Application not happy. I've tried a number of options in the Import wizard (ansi padding etc) and it
seems to have had no effect. Any ideas? Solutions? KB articles?
Thanks for ANY help.
-J
By definition, a char(10) is always padded with spaces up to the length of the datatype. This is why we call
char a fixed length datatype. If you want a variable length datatype, use varchar.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"JManton" <anonymous@.discussions.microsoft.com> wrote in message
news:D89560CC-AAAB-459C-A039-8073C17EB2ED@.microsoft.com...
> I'm moving a small application from a MySQL db to MSSQL2K and using the Import feature of SQL2K. The db in
question is simple, only three tables, mostly text (CHAR) fields. The problem is that when I examine the
field contents I find that the unused character positions within the fields have been padded with trailing
spaces. (Example: original 10 char field containing "ABC" now contains "ABC ". Application not happy.
I've tried a number of options in the Import wizard (ansi padding etc) and it seems to have had no effect.
Any ideas? Solutions? KB articles?
> Thanks for ANY help.
> -J
|||That was it. I guess there are a few diffs between MySQL and MSSQL. I also had to tweak the recordID field and use IDENTITY attribute. Thanks for the quick reply and on-the-mark-help.
-J

No comments:

Post a Comment