How to change the database server for case sensitive

  • hi,

    In my database I created one table and add one column.

    column name is : column1 ..

    when i used select query select .

    select COLUMN1 FROM table ..

    it showing data.. how can i change the database to case sensitive..

    I am using sql server 2005 ctp expressedition..

    regards:

    giri...

    Thanks
    Dastagiri.D

  • So whats the proble it must not show column1 when give COLUMN1.

    I dont think there is an option for that.

    Tanx 😀

  • Hi,

    you can change the server collation, check http://msdn.microsoft.com/en-us/library/ms179254.aspx

    Regards,

    René

  • Note that you can also change your database, or table collation as well (if you don't want your entire server running that way)

    So if you're using SQL_Latin1_General_CP1_CI_AS, try SQL_Latin1_General_CP1_CS_AS

    ALTER DATABASE COLLATE SQL_Latin1_General_CP1_CS_AS

  • Why do you want to change to case sensitive?

    "Keep Trying"

  • You do not have to change the database or column collation in order to use different collations for specific tasks. In fact you can mix collations to match your needs.

    If you have your database built with case insensitve collation but would like to do case sensitive search just use the COLLATE keyword.

    For example the first select will find all records where test code is 'ABC' regardless of the case - so abc, AbC aBc and such will be found. The second one will find only the record matching the case of the specified string 'ABC' in this case. The third example will mix the case sensitive and case insensitive search in one query.

    SELECT * FROM Tests

    WHERE TestCode = 'ABC'

    SELECT * FROM Tests

    WHERE TestCode = 'ABC' COLLATE Latin1_General_CS_AS

    SELECT * FROM Tests

    WHERE TestCode = 'ABC' COLLATE Latin1_General_CS_AS

    OR TestCode = 'CBS'

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

  • Note that changing server or database collation does NOT change the collation for pre-existing columns/data. There's only one way to do that:

    Create a brand new empty database in the desired collation and migrate the data into that DB.

    Simplest thing to do is to use the COLLATE option, though (as mentioned above).

    MSSQLTIPS just had an article on that today: slightly different context but same issue

  • To set or change the database collation

    1. In Object Explorer, connect to an instance of the SQL Server Database Engine, expand that instance, and then expand Databases.
    2. If you are creating a new database, right-click Databases and then click New Database. If you do not want the default collation, click the Options page, and select a collation from the Collation drop-down list.

      Alternatively, if the database already exists, right-click the database that you want and click Properties. Click the Options page, and select a collation from the Collation drop-down list.

    3. After you are finished, click OK.
      This will restrict on case for overall database

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply