By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,652 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,652 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.