Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Why trailing spaces are trimmed

Author  Topic 

geossl
Yak Posting Veteran

85 Posts

Posted - 2004-04-22 : 00:32:07
Dear All,
I am getting the delimiter from a field in database table but the trailing spaces are trimmed. Is there any way to get the trailing spaces without being trimmed?

The datatype of the field in the table is varchar.

Thanks.

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2004-04-22 : 03:54:16
The ANSI_PADDING setting for the database might have been turned off. Try this SET ANSI_PADDING ON, this preserves trailing spaces in varchar columns. You will have to recreate the table for the changes to take effect.

OS
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-04-22 : 06:17:50
If the data type is changed to CHAR
you shouldn't loose trailing spaces.


Duane.
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2004-04-22 : 07:39:42
quote:
Originally posted by ditch

If the data type is changed to CHAR
you shouldn't loose trailing spaces.



...but you might gain some. With char, there is no way of identifying how many spaces were added by the user, and which have been padded on by SQL Server.

OS
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-04-22 : 07:42:09
Good point!

Duane.
Go to Top of Page
   

- Advertisement -