Q:

Unrecognized function name in SQL Server 2008 R2

When ever I try to execute the following I get 
Msg 195, Level 15, State 10, Line 1
'dbname' is not a recognized built-in function name.
USE Personnel
GO
SELECT has_perms_by_name(dbname(), 'OBJECT', 'SELECT') as Have_Select,
* from sys.tables;
GO

I'm not sure if dbname() should be got replaced or if its a syntax error.

A:

You probably want the following which I've confirmed works:
USE Personnel
GO
SELECT has_perms_by_name(DB_NAME(), 'OBJECT', 'SELECT') as Have_Select, 
* from sys.tables;
GO

And as per a comment it's not case-sensitive, the problem was the missing underscore.

