469,648 Members | 1,172 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

SQL 2000 padding char with spaces for a type 4 JDBC driver

Please help!!!

We had a sql server 7 DB, with a char 8 field, in which some of the
data was only 7 characters in length.
Via a type 4 JDBC driver, we got back a NON space padded String.

This server got upgraded to sql server 2000. Now, via the type 4 JDBC
driver, we get a String padded field!!

I understand there is a ODBC setting for ANSI padding on/off, but the
type 4 doesn;t use the OdBC-JDBC bridge...so configuration could be
affecting the data coming back?

No one here can work out why. Any ideas?
Jul 20 '05 #1
1 2020
Prithpal (pr***********@talk21.com) writes:
We had a sql server 7 DB, with a char 8 field, in which some of the
data was only 7 characters in length.
Via a type 4 JDBC driver, we got back a NON space padded String.

This server got upgraded to sql server 2000. Now, via the type 4 JDBC
driver, we get a String padded field!!

I understand there is a ODBC setting for ANSI padding on/off, but the
type 4 doesn;t use the OdBC-JDBC bridge...so configuration could be
affecting the data coming back?


ANSI_PADDING has to do with how data is stored in varchar columns.
If you have the string 'ABC ' how is to be stored in a varchar(10)
column? Old Sybase and SQL Server stripped the spaces and saved 'ABC'.
ANSI calls for 'ABC ', and that's what you get with ANSI_PADDING.

Since a char column is fixed length, it should always be padded. I don't
know the details about your drivers, but the behaviour you get with SQL2000
sounds correct to me. A char(8) value is a eight-character value.

If you don't want that extra space, you should be using varchar instead.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.