Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Case Sensitivity

Author  Topic 

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2007-07-07 : 01:47:54
Hi I have two questions about case sensitivity;
1. Do most people write their queries with UPPERCASE keywords or is that only for the textbooks. Personally I find it a hassle, My little finger aches because it is always on and off the SHIFT key
2. I noticed that when I did the following query
-----------------------------
use AdventureWorks
go
Select * employee
-----------------------------
I get an 'invalid object' message
But if I use;
--------------------------
use AdventureWorks
go
Select * Employee
--------------------
It works. SO obviously the query is case sensitive.
Did this use to be the case with SQL 2000. I don't seem to remember having to be careful about case.

THANKS

sachinsamuel
Constraint Violating Yak Guru

383 Posts

Posted - 2007-07-07 : 02:17:07
1. Do most people write their queries with UPPERCASE keywords or is that only for the textbooks. Personally I find it a hassle, My little finger aches because it is always on and off the SHIFT key

Answer: Its a good practice to write queries in upper case, as if u follow this accross all your database objects then the code looks neat.




I will give you a tip which I use. Write your sql statement/code in anycase and then select the code/statement and press Shift+Ctrl+u keys. All the code will be converted to uppercase. The reverse can be done by using Shift+Ctrl+l keys.

Try and let me know incase you have any trouble.



2. I noticed that when I did the following query
-----------------------------
use AdventureWorks
go
Select * employee
-----------------------------
I get an 'invalid object' message
But if I use;
--------------------------
use AdventureWorks
go
Select * Employee
--------------------
It works. SO obviously the query is case sensitive.
Did this use to be the case with SQL 2000. I don't seem to remember having to be careful about case.



Answer: Its because your database collation is set to be case sensitive. You check the database collation setting by right clicking the database. Go general section and check the Maintainance section

For my user database I have set it to "SQL_Latin1_General_CP1_CI_AS". The character "CI" defines Case insensitive. I am sure this must be "CS" in your case. You can change this by alter database command. Please check the below url for the same.



http://expertanswercenter.techtarget.com/eac/knowledgebaseAnswer/0,295199,sid63_gci1054949,00.html

Don't sit back because of failure. It will come back to check if you still available. -- Binu
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-07-07 : 11:25:57
Or you installed sql instance with case sensitive collation. How to write query depends on db object's collation.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-07 : 11:57:00

http://weblogs.sqlteam.com/mladenp/archive/2006/12/07/44176.aspx

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-07 : 16:45:05
I think you should write
Select * from Employee
not
Select * Employee


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2007-07-08 : 01:12:13
Thanks a lot for the info.
PS OI just copied the query wrong i did originally have "SELECT * FROM"
Go to Top of Page
   

- Advertisement -