Results 1 to 6 of 6

Thread: Case sensitivity

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    39
    Does anyone know if SQL Server is case sensitive? I ask this because when I perform comparisons between string variables and fields in ADODB Recordsets case does not seem to matter. For example, if I compare hello and HELLO, they are considered the same string. However, my application needs to be case sensitive.

    Does anyone know what could be happening, and how I can "turn on" this case sensitivity?

    I think it may have something to do with the Option Compare statement, but by default it should be a binary compare.

    TIA,

    Nahid

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Lightbulb

    SQL Server is case sensitive. If you want clarification about the framing of queries through VB, just give me an example of how you are writing your queries. Many of us will be able to help you.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    SQL Server is NOT case sensitive by default. It is an option during installation of SQL, but then your entire SQL Server would be case sensitive (ALL the databases).

    You might have to add an extra step in your program to compare the SQL results with your string and make sure they match (VB is case sensitive)

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    39
    Clunietp,

    Thanks for the help. The thing that is confusing me is that all my comparisons ARE done in VB, and yet even when case doesn't match but the words are the same, the comparison operation returns true. For example, if I do:

    if (rcset_master!String = "hello") then
    debug.print "True"
    end if

    and the String field of rcset_master contains "HELLO", "True" will show up in the immediate window.

    Any ideas why that happens?

    Thanks,

    Nahid

  5. #5
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    I don't know, this code works correctly in evaluating the case sensitivity:

    Code:
        Dim cn As New Connection
        Dim rs As Recordset
        
        'connect to Northwind DB
        cn.Open <ConnectionString>
        
        Set rs = cn.Execute("Select * from Customers")
        
        Debug.Print rs!CustomerID   'will be ALFKI
        
        MsgBox rs!CustomerID = "alfki"  'shows FALSE
        MsgBox rs!CustomerID = "ALFKI"  'shows TRUE
    This uses ADO 2.5 and SQL 7 DB

  6. #6
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well, harjeen ....

    Your code looks OK. It should work in any 'case'. Just a moment, you are using debug.print, right? Could you try using the 'MsgBox' instead?
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width