Tuesday, April 5, 2011

Are SQL stored procedures case sensitive?

for example...

ALTER PROCEDURE [dbo].[Reports_Dashboard_Get_Sav]   
    -- Add the parameters for the stored procedure here
    @startDate datetime,
    @endDate datetime,
    @companyID int=null

set @days=datediff(m,@startdate,@enddate)
if (@days)=0 
    set @days=1

This is not my code but if this is case sensitive then @days is not going to be calculated properly as the startDate/startdate and endDate/enddate variables don't match...

From stackoverflow
  • No. Not T-SQL at least...

  • As I recall, they are not case sensitive for the SQL commands themselves, I've routinely seen them written as lowercase. I'm pretty sure the rest is case-insensitive as well given that its an extension of the T-SQL spec.

  • They can be, depending on your database's collation. When you install SQL Server and choose your default collation, you'll notice that there's a "case sensitivity" checkbox. Certain collations are case sensitive and will affect your queries (and stored procedures).

    Worse still, many vendors don't test their products on servers with case sensitive collations, which leads to runtime errors.

    dbones : argh you beat me -- here is a link tho http://aspadvice.com/blogs/ssmith/archive/2007/09/30/Case-Sensitive-or-Insensitive-SQL-Query.aspx
    Michael Haren : Does that apply to variable names? Or just data?
    Russ Cam : I was surprised to find this out when we gained access to another database at work - not only were database objects case sensitive but so were queries against table data.
    Cade Roux : But your query won't run if it can't find the objects - it's not just going to silently insert NULLs or anything. Now it might not think a table exists, but in a LEFT JOIN, say, you aren't going to just get NULLs because a table is not in the right case, you'll get an error.
    Russ Cam : @Cade, that's true

0 comments:

Post a Comment