Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Truncate fields when connection to MSSQL with ADO

Status
Not open for further replies.

Nordlund

Programmer
Jul 17, 2001
458
SE
Hi there.
This is a combined problem with MSSQL, hope anyone can help
Why I post it here is that it seems to pop up only in Delphi

If I'm connecting to a MSSQL server with the ADO components, I get non-truncated data in return when selecting from the server. Is there a way to eleminate the rightmost spaces in any way?

I've tried to convert my CHAR(10) fields to VARCHAR(10), but I get the trailing spaces anyway.





//Nordlund
 
Hi.
That's the problem...
We are talking about 150000 rows of code and 150 tables with a bunch of fields.

It's not possible to trim everyting in the aplpication...
I was hoping there was someting I could do in the Connection object ot the Query object.

//Nordlund
 
if you want just the spaces on the right gone, use TrimRight. If I'd want to do something with the conection I'd try to send compressed memory streams.

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Yeps. There is a TRIM function, but I cant use it,
because I would be forcded to edit several hundred SQL queries.

The only solution has to be to remove the trailing spaces directly on the SQL server... Och if possible, truncate them autamatically at the client.

I prefer the first solution, because it the network data packets would be a little bit smaller, and the bandwith aspect would be more efficient.

//Nordlund
 
I had to solve ut with some gigantic update queries...
Not nice, but it's working.... On small tables at least... :)

Code:
UPDATE TableX
  SET f1 = RTRIM(f1),
      f2 = RTRIM(f2),
      f3 = RTRIM(f3),

//Nordlund
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top