Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"-" Causing Query To Fail

Status
Not open for further replies.

SHelton

Programmer
Jun 10, 2003
541
GB
Can anyone advise why storing the name "Karen-Ann McCabe" in a varchar(50) column returns a LEN value of 18 ? I have checked that there are no extra characters at the end of the name.

This is causing queries to fail when the look for the exact string. If I add the % wildcard to the end the record is found.

Any suggestions ?
 
Plz. run this and post results here:

Code:
declare @data varchar(50)
select @data = <retrieve Karen-Ann McCabe here>

declare @t table (c char(1), value smallint)
declare @i int; set @i = 1
while @i <= len(@data)
begin
	insert into @t values ( substring(@data, @i, 1), ascii(substring(@data, @i, 1)) )
	set @i = @i + 1
end

select * from @t

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Thanks vongrunt:
Code:
K	75
a	97
r	114
e	101
n	110
-	45
A	65
n	110
n	110
 	32
M	77
c	99
C	67
a	97
b	98
e	101
 	13
 	10
So how did a CRLF get in there ?
 
You tell me :X

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top