Tuesday, March 27, 2012

Case Senstivity on SQL Server

I have written several stored procedures on my local SQL server database.
Through my coding i will occasionally change the case of a variable. For
example I will declare a variable @.SQL varchar(20) but later call it @.sql
(lower case).
My sql server isn't case sensitive, but other databases I have loaded the
stored procedure are. How can I change the SQL server settings to not be
case sensitive? Plus how I can I change it back if it screws something up
with other applications that use other databases on the server? Is it a
server setting or database setting?
Thanks in advance!
Matt,
You will be much better off correcting the uppercase/lowercase
inconsistencies in your stored procedures. The most reasonable
assumption is that the server and database collations were chosen for a
good reason, but it doesn't sound like there's any reason you need to
vary the case in your procedures. To answer your question, yes, it can
break things if you change the collation of a database. One of the more
likely things that can happen is that it will cause data type
conversions that make indices impossible to use, slowing down performance.
The collation of the server instance is set when the instance is
installed. You can change database collations with ALTER DATABASE, but
why risk breaking things because you don't want to take the time to be
more careful coding?
Steve Kass
Drew University
Matt Tapia wrote:

>I have written several stored procedures on my local SQL server database.
>Through my coding i will occasionally change the case of a variable. For
>example I will declare a variable @.SQL varchar(20) but later call it @.sql
>(lower case).
>My sql server isn't case sensitive, but other databases I have loaded the
>stored procedure are. How can I change the SQL server settings to not be
>case sensitive? Plus how I can I change it back if it screws something up
>with other applications that use other databases on the server? Is it a
>server setting or database setting?
>Thanks in advance!
>
>
>

No comments:

Post a Comment