Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Mysterious text in query result
Hi,

I have a database with a column defined as varchar(100) called Surname.
When I use Query Analyzer to retrieve data from the column and display as
text, I get strange text appearing for one of the records.  Thus, the field
contains "Wilson" but when I run the following:

SELECT '''' + Surname + '''', Surnname FROM tblManagers
WHERE FirstName = 'Glenn'

I get the following result:

'Wilson d  g e d   w i t h   t h e   a '                   Wilson

Where has the "d ged with the a" come from.  If I show the results in a grid
the final apostrophe is missing from the first part of the query:

'Wilson

If I run a query using ADO and show the result on a web page, the extra text
is not shown.

Any ideas what is going on here?

Glenn

Report this thread to moderator Post Follow-up to this message
Old Post
BigMan2001
03-24-06 12:39 PM


Re: Mysterious text in query result
[Reposted, as posts from outside msnews.microsoft.com does not seem to m
ake
it in.]

BigMan2001  (BigMan2001@discussi
ons.microsoft.com)  writes:
> I have a database with a column defined as varchar(100) called Surname.
> When I use Query Analyzer to retrieve data from the column and display
> as text, I get strange text appearing for one of the records.  Thus, the
> field contains "Wilson" but when I run the following:
>
> SELECT '''' + Surname + '''', Surnname FROM tblManagers
> WHERE FirstName = 'Glenn'
>
> I get the following result:
>
> 'Wilson d  g e d   w i t h   t h e   a '                   Wilson
>
> Where has the "d ged with the a" come from.  If I show the results in a
> grid the final apostrophe is missing from the first part of the query:
>
> 'Wilson
>
> If I run a query using ADO and show the result on a web page, the extra
> text is not shown.

Looks like some junk data slipped in, and there is a NUL character hiding
there. See what

SELECT  convert(varbinary(10
0), Surname) FROM tblManagers
WHERE FisttName = 'Glenn'

returns.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.seBooks Online for SQL
Server 2005
athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000
athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Report this thread to moderator Post Follow-up to this message
Old Post
Erland Sommarskog
03-27-06 01:26 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server Tools archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 06:08 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006