Skip to main content
replaced http://dba.stackexchange.com/ with https://dba.stackexchange.com/
Source Link

If there is any sane reason to ignore trailing blanks in varchar comparisons, why doesn't that apply to tab-characters too ?

On SQL Server I get

SELECT
    case when '' = ' ' then 'true' else 'false' end, 
    case when '' = CHAR(9) then 'true' else 'false' end

yields

---- -----
true false

Is this a problem of the ANSI specification or a problem of the SQL Server implementation?

Edit:

I do not have access to the text of the specification. I only see it mentioned in this answeranswer. I can't tell if it addresses only blanks or if it refers to whitespace in some vague sense.

If there is any sane reason to ignore trailing blanks in varchar comparisons, why doesn't that apply to tab-characters too ?

On SQL Server I get

SELECT
    case when '' = ' ' then 'true' else 'false' end, 
    case when '' = CHAR(9) then 'true' else 'false' end

yields

---- -----
true false

Is this a problem of the ANSI specification or a problem of the SQL Server implementation?

Edit:

I do not have access to the text of the specification. I only see it mentioned in this answer. I can't tell if it addresses only blanks or if it refers to whitespace in some vague sense.

If there is any sane reason to ignore trailing blanks in varchar comparisons, why doesn't that apply to tab-characters too ?

On SQL Server I get

SELECT
    case when '' = ' ' then 'true' else 'false' end, 
    case when '' = CHAR(9) then 'true' else 'false' end

yields

---- -----
true false

Is this a problem of the ANSI specification or a problem of the SQL Server implementation?

Edit:

I do not have access to the text of the specification. I only see it mentioned in this answer. I can't tell if it addresses only blanks or if it refers to whitespace in some vague sense.

added 252 characters in body
Source Link
bernd_k
  • 12.3k
  • 24
  • 78
  • 111

If there is any sane reason to ignore trailing blanks in varchar comparisons, why doesn't that apply to tab-characters too ?

On SQL Server I get

SELECT
    case when '' = ' ' then 'true' else 'false' end, 
    case when '' = CHAR(9) then 'true' else 'false' end

yields

---- -----
true false

Is this a problem of the ANSI specification or a problem of the SQL Server implementation?

Edit:

I do not have access to the text of the specification. I only see it mentioned in this answer. I can't tell if it addresses only blanks or if it refers to whitespace in some vague sense.

If there is any sane reason to ignore trailing blanks in varchar comparisons, why doesn't that apply to tab-characters too ?

On SQL Server I get

SELECT
    case when '' = ' ' then 'true' else 'false' end, 
    case when '' = CHAR(9) then 'true' else 'false' end

yields

---- -----
true false

Is this a problem of the ANSI specification or a problem of the SQL Server implementation?

If there is any sane reason to ignore trailing blanks in varchar comparisons, why doesn't that apply to tab-characters too ?

On SQL Server I get

SELECT
    case when '' = ' ' then 'true' else 'false' end, 
    case when '' = CHAR(9) then 'true' else 'false' end

yields

---- -----
true false

Is this a problem of the ANSI specification or a problem of the SQL Server implementation?

Edit:

I do not have access to the text of the specification. I only see it mentioned in this answer. I can't tell if it addresses only blanks or if it refers to whitespace in some vague sense.

added 18 characters in body
Source Link
gbn
  • 70.1k
  • 8
  • 165
  • 242

If there is any sane reason to ignore trailing blanks in varchar comparisons, why doesn't that apply to tab-characters too ?

On SQL Server I get

SELECT
    case when '' = ' ' then 'true' else 'false' end , 
    case when '' = CHAR(9) then 'true' else 'false' end

yields

---- -----
true false

Is this a problem of the ANSI specification or a problem of the SQL Server implementation?

If there is any sane reason to ignore trailing blanks in varchar comparisons, why doesn't that apply to tab-characters too ?

On SQL Server I get

SELECT case when '' = ' ' then 'true' else 'false' end , case when '' = CHAR(9) then 'true' else 'false' end

yields

---- -----
true false

Is this a problem of the ANSI specification or a problem of the SQL Server implementation?

If there is any sane reason to ignore trailing blanks in varchar comparisons, why doesn't that apply to tab-characters too ?

On SQL Server I get

SELECT
    case when '' = ' ' then 'true' else 'false' end, 
    case when '' = CHAR(9) then 'true' else 'false' end

yields

---- -----
true false

Is this a problem of the ANSI specification or a problem of the SQL Server implementation?

Source Link
bernd_k
  • 12.3k
  • 24
  • 78
  • 111
Loading