Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stored Procedure returning no results
Message
From
30/05/2012 10:21:04
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01544680
Message ID:
01544769
Views:
20
>>>>Hi Naomi,
>>>>
>>>>I removed the last two lines from the WHERE clause and ran it again and I don't get any results returned.
>>>
>>>It means that your field is saved with some extra characters. Get this row using +% and then examine that field's content - it can have some extra characters saved you don't see.
>>
>>I don't follow your logic. :(
>>
>>This is being done in SSMS where I have "hardcoded" the value 'WLIF20120047' as the value of the parameter like this:
>>
>>declare @PolicyNumber nvarchar(20)
>>set @PolicyNumber = 'WLIF20120047'
>>
>>so it is impossible to have other characters in there, isn't it?
>
>I mean that the field has other invisible characters, otherwise that row have been found. Get that row, copy the field content and then examine it in the Hex Editor.
>
>Here is a simple test that shows that even spaces saved in the field matter:
>
>DECLARE @Test TABLE (Fld1 nvarCHAR(50))
>INSERT INTO @Test VALUES ('WLIF20120047       ')
>insert into @test values('WLIF20120047' + replicate(char(9),4))
>
>declare @PolicyNumber nvarchar(20)
>set @PolicyNumber = 'WLIF20120047'
>
>SELECT * FROM @Test WHERE Fld1 LIKE @PolicyNumber
>SELECT * FROM @Test WHERE Fld1 = @PolicyNumber -- this returnes result
>
>
>In other words, seems like LIKE comparison doesn't work when there are some extra characters in the field even spaces. = ignores spaces.

Ah, got you now. You are right, it has blank characters at the end of it. I will see how this is getting into the field and fix it. Thanks.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform