473,388 Members | 1,073 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Why select ... where 'Anna ' = 'Anna' returns TRUE?

Sorry for asking stupid questions...

I can't remember which settings in MS SQL define the behaviour of this comparison:

select * from table where 'Anna ' = 'Anna'

to be TRUE. Both strings are different because the first contains trailing blanks.

How to change it to return FALSE what is my expected value?
Jul 20 '05 #1
2 2472
ae***@op.pl (Robert Zientara) wrote in message news:<de**************************@posting.google. com>...
Sorry for asking stupid questions...

I can't remember which settings in MS SQL define the behaviour of this comparison:

select * from table where 'Anna ' = 'Anna'

to be TRUE. Both strings are different because the first contains trailing blanks.

How to change it to return FALSE what is my expected value?


You may be thinking of SET ANSI_PADDING, but that applies to how
strings are stored in tables, not how they are compared. SQL Server
ignores trailing blanks for non-Unicode data:

http://support.microsoft.com/default...;en-us;Q316626

It would be useful to know the data types of the columns/variables
you're working with, but one possible query to get only exact matches
(on the basis of the length of the string) might be this:

select *
from table
where column = 'Anna' and
datalength(column) = datalength('Anna')

Simon
Jul 20 '05 #2
"Robert Zientara" <ae***@op.pl> wrote in message
news:de**************************@posting.google.c om...
Sorry for asking stupid questions...

I can't remember which settings in MS SQL define the behaviour of this comparison: select * from table where 'Anna ' = 'Anna'
to be TRUE. Both strings are different because the first contains trailing blanks. How to change it to return FALSE what is my expected value?


Check .... SET ANSI_PADDING

Also RTRIM

Pete Brown
Falls Creek
Oz
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Reestit Mutton | last post by:
Hi, I'm currently learning the ropes with CSS, PHP, MYSQL, Javascript etc... by redesigning my website as a database driven site. Okay, so I'm skilled at perl, data manipulation and data...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
4
by: Anna | last post by:
Hi all, I have a query in ASP.NET that selects text from a memo field in Access (among other things). The query appears to be truncating the text at 255 characters. I've done a little research...
4
by: Anna Smith | last post by:
I have an extremely long and complex select statement as shown below and I need to split it onto two lines but not quite sure how to do it because I've never needed to before. I need to split it...
1
by: Christopher DeMarco | last post by:
Hi all... I've written a class to provide an interface to popen; I've included the actual select() loop below. I'm finding that "sometimes" popen'd processes take "a really long time" to...
2
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
2
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code...
2
by: Sektor | last post by:
Hi guys, I have just a problem with the Select timeout parameter. The MSDN tells us: microSeconds The time-out value, in microseconds. A -1 value indicates an infinite time-out. I try to use...
5
by: OldBirdman | last post by:
I am attempting to assign a .RowSource to a ListBox using an SQL statement. I want to build the SQL statement "On-the-Fly", based on values in several controls on the form. I would like to restrict...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.