473,382 Members | 1,204 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,382 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 2471
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.