Re: varchar problem



Geoff Berrow wrote:
I noticed that Message-ID: <42b378b7$1_1@xxxxxxxxxxxxxxxxxxxxxxxxx> from
Terry contained the following:


I apparently do not correctly understand varchar - everything I have read indicates that text entered into a MySQL table with varchar characteristics will automatically have any space characters stripped

from both ends of the line.

Where have you read that? A space is just another character. If you want to strip them, use trim().

From page 123 of "PHP and MySQL for Dynamic Web Sites" by Larry Ullman:
---------
Heading "Char vs. Varchar"
One primary difference between the two is that anything stored as CHAR will always be stored as a string the length of the column (using spaces to pad it). Coversely, VARCHAR strings will only be as long as the stored string itself.
---------
- a google search yielded simular results.


The filename (row[0]) is varchar and has no extra spaces.
Some of the entries (row[3]) have leading spaces - most do not.
Additionaly, I did not put any spaces in - why should I have to strip them?

--
TK
http://www.wejuggle2.com/
Still Having a Ball







..

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
.



Relevant Pages

  • Re: DTS bug (?): Data Driven Query Task incorrectly replaces empty strings with NULL.
    ... CHAr and VARCHAR and the ANSI PADDING settings so I do not think it as easy ... > The problem with converting an empty VARCHAR string to a CHAR string is ... > VARCHAR, instead of an empty string, I get a string with 50 spaces. ...
    (microsoft.public.sqlserver.dts)
  • Re: DTS bug (?): Data Driven Query Task incorrectly replaces empty strings with NULL.
    ... CHAr and VARCHAR and the ANSI PADDING settings so I do not think it as easy ... > The problem with converting an empty VARCHAR string to a CHAR string is ... > VARCHAR, instead of an empty string, I get a string with 50 spaces. ...
    (microsoft.public.sqlserver.server)
  • Re: varchar problem
    ... A space is just another character. ... >> want to strip them, ... VARCHAR strings will only be as long as ... > the stored string itself. ...
    (alt.php)
  • RE: ADO.NET 2.0 saving single space to SQL?
    ... It turns out that changing the parameter to a type of varchar or using the ... Fields that are being inserted into the database as a zero length ... string in 1.1 contain a single space when inserted with 2.0 compiled code. ... The code specifies a stored proc to run and set up the parameter collection. ...
    (microsoft.public.dotnet.framework.adonet)
  • Not getting all data from Stored Procedure.
    ... I am trying to get the identity of a row I add in my stored procedure. ... Dim ConnectionString as String ... @srvname varchar, ...
    (microsoft.public.dotnet.framework.aspnet)