Q
Problem solve Get help with specific problems with your technologies, process and projects.

How can I delete empty spaces from a text column?

How can I delete empty spaces from a text column?
Well, I'm going to make some guesses about your exact scenario in order to provide an answer that might be useful. Of course, if I get any of these assumptions wrong, it won't help you (but others might learn something). I am going to assume that you are using SQL Server 2000 with a table that has a column defined as text.

In that scenario, you have several options for storing the data: For a text data type, you can specify the "text in row" option to store the data in the row with the rest of the data, or you can turn off that option and have the data stored in a separate area.

Either way, you can get the exact length of the data in the column using the DATALENGTH function (for example, DATALENGTH(pubbame)). Then you could use the SUBSTRING function to return only the part of the column that contains data.

If you are using a text (or ntext for Unicode) data type, the column is variable length and the "empty spaces" should not be stored.

If you are using a char data type, consider switching to text (or perhaps varchar) to implement a variable length column.

Hope this helped.

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close