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
 SQL Server Development (2000)
 Upload large data in the database retaining the format

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-11-22 : 07:44:18
Narmy writes "I am trying to upload articles in my sql database. The data does get stored in the database, but when I retrieve it and display it, it loses its format. Is there some specific way in which I should be storing the data?
I looked up for field types for storing large data and I have worked accordingly, but somehow I am not able to retain the format such as line breaks and indentation."

surendrakalekar
Posting Yak Master

120 Posts

Posted - 2005-11-23 : 01:38:42
It is because of the NON PRINTABLE ASCCI characters. Try one thing....
Find out one record, which is loses its format. Update all the NON PRINTABLE ASCII characters with empty string ('') and disply it. It should work... :-)

Just try the below function to remove all the NON PRINTABLE ASCCI characters.

CREATE FUNCTION dbo.NonPrintableASCIICharOnly (@DataString varchar(8000))
RETURNS varchar(8000)
AS
BEGIN
DECLARE @Index INT,
@ASCIIDataString varchar(8000),
@ASCIIChar INT
-- Initialization code
SET @Index = 1
SET @ASCIIDataString = ''

WHILE @Index < LEN(@DataString)+1
BEGIN
SET @ASCIIChar = ASCII(SUBSTRING(@DataString, @Index, 1))
--Restrict the result to A-Z and a-z
IF @ASCIIChar in (9,10,13) or @ASCIIChar BETWEEN 32 and 126
BEGIN
-- Construct the output characters
SET @ASCIIDataString = @ASCIIDataString + CHAR(@ASCIIChar)
END
SET @Index = @Index + 1
END
RETURN @ASCIIDataString
END

Surendra
Go to Top of Page
   

- Advertisement -