Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8486425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:56:33+00:00 2026-06-10T20:56:33+00:00

For example, if I have this data: CREATE TABLE FooBar ( Name varchar(16) )

  • 0

For example, if I have this data:

CREATE TABLE FooBar ( Name varchar(16) )

INSERT FooBar SELECT 'test@test.com'

The following queries don’t return what I would expect:

SELECT * FROM FooBar WHERE Name = 'test@test.com       '  -- Returns the row

SELECT * FROM FooBar WHERE Name LIKE 'test@test.com '  -- Nothing Returned

SELECT * FROM FooBar WHERE Name = ' test@test.com' -- Nothing Returned

Why does = (which I assume means exactly equals) with extra space at the end return data, while a LIKE does not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:56:34+00:00Added an answer on June 10, 2026 at 8:56 pm

    Seing the standard it depends on padding (The ANSI standard requires padding for the character strings used in comparisons so that their lengths match before comparing them)

    SQL Server follows the ANSI/ISO SQL-92 specification (Section 8.2, ,
    General rules #3) on how to compare strings with spaces. The ANSI
    standard requires padding for the character strings used in
    comparisons so that their lengths match before comparing them. The
    padding directly affects the semantics of WHERE and HAVING clause
    predicates and other Transact-SQL string comparisons. For example,
    Transact-SQL considers the strings ‘abc’ and ‘abc ‘ to be equivalent
    for most comparison operations.

    The only exception to this rule is the LIKE predicate. When the right
    side of a LIKE predicate expression features a value with a trailing
    space, SQL Server does not pad the two values to the same length
    before the comparison occurs. Because the purpose of the LIKE
    predicate, by definition, is to facilitate pattern searches rather
    than simple string equality tests, this does not violate the section
    of the ANSI SQL-92 specification mentioned earlier.

    See also how SQL Server compares strings with trailing spaces

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have sqlite3 database with example structure and data: CREATE TABLE person(id INTEGER PRIMARY
I have this SQL table: CREATE TABLE DATA ( ID NUMBER NOT NULL, CODE
Example i have this table table transaction id int (PK) unit varchar(10) journal_number journal
I have a SQlite3 table that has typeless columns like in this example: CREATE
I have a file containing some data (for example, 00927E2B112DB958......). This data is a
For example I have a method that looks like this [self performSelectorOnMainThread:@selector(someMethod) withObject:data waitUntilDone:YES];
I have a list within a data frame (in this example, df$candpct ), and
I have this example FactoryGirl.define do @site = FactoryGirl.create(:my_site) factory :user do email {
I have a table, which holds (besides all other data) information, when this data
in java we have this name space javax.persistence. this namespace allows you to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.