Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS SQL data - strange character but no show in the actual table when submitting a form

Posted on 2006-06-26
10
Medium Priority
?
689 Views
Last Modified: 2008-07-02
I have a form which submits data to an MSSQL table.  This table then submits to our backend system.

There is a problem only at certain times with the data submitting to the backend.  In MSSQL, it shows nothing.  When I copy the data over to textpad or wordpad to view the records, I see something very strange.

First of all, we do a check and take out all weird characters before we submit to MSSQL - including !@#$%^&*()_+=-,./<>?;':"[]\{}| etc.

Then we enter the form into mssql table.

In the table, all looks well.

When I extract the files to a text document, this is what I see for the normal submissions:

BILL          1 address       city   state    zip

**********
for the ones that come across and cause errors in our backend system, this is what I see in text editor:

BILL         "1 Address
"               city           state            zip

Does anyone know what causes this and what I can do to eliminate the problem?

0
Comment
Question by:foreverdita
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 25

Expert Comment

by:dstanley9
ID: 16984734
Check for carriage returns (CHR(13)) and line feeds (CHR(10)) in your text.  Some text editors will show a single CR or LF, some will only show if they are together (CRLF) - this is Windows style.
0
 
LVL 28

Expert Comment

by:imran_fast
ID: 16984762
In Query Analyzer select the column from the table and check the accii code for that character
ascii('a)' and try to replace this ascii with empty string

But obviously it is coming from one of the client machine so you have to identify that client machine and then  check for regional setting for that client machine.
0
 

Author Comment

by:foreverdita
ID: 16984901
How would I check for carriage returns by sleecting * from table where Ad1 has a carriage return?  In query Analyzer I mean?
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:foreverdita
ID: 16984910
select * from address where ad1 has a carraige return (how do I check for carriage return here)

 
0
 
LVL 4

Expert Comment

by:kenpem
ID: 16984918
In your weird-character check, you should also remove anything below CHAR(32) as these are all non-printable control characters. Possibly everything above CHAR(126) as well. This should render everything neatly viewable.
0
 
LVL 4

Assisted Solution

by:kenpem
kenpem earned 400 total points
ID: 16984940
SELECT * FROM address WHERE ad1 LIKE ('%'+CHAR(13)+'%')

will show you which records contain a carriage return. Also check for CHAR(10) for line-feeds.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16985968
>>Possibly everything above CHAR(126) as well. <<
Ouch!  You have just knocked out Latin America and most of Europe.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16986000
>>Does anyone know what causes this and what I can do to eliminate the problem?<<
It means you have a CrLf or Cr at the end of the Address column.  This is easy to confirm:
1. Open the table in Enterprise Manager
2. Select the row that is causing the problem.
3. Go into Edit mode (F2) and the value should disappear (it is actually there, you are just on the second line).  On other cells when pressing F2 you will see the value highlighted and you will remain on the same line.
0
 

Author Comment

by:foreverdita
ID: 16986672
OK, then upon a form submittal, how would I get rid of the CHAR(13) before submitting the contents of the form?

theaddress = replace(ad1, ""+Char(13)+"", "")

Or something like that?

Also, is there a way to replace existing records in the table that have char13 without erasing the entire ad1?
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 1600 total points
ID: 16986822
To fix existing records:

UPDATE address
SET ad1 = REPLACE(ad1,CHAR(13),'')

To fix on the form:

theaddress = ad1.Replace( "\n", "");  // CHR(10)
or
theaddress = ad1.Replace( "\r", "");   // CHR(13)
or
theaddress = ad1.Replace( "\r\n", "");  //CHR(13)+CHR(10)

depending on which character(s) is causing the problem.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question