aleksey donskoy (1/8/2014)
[DBName] varchar(65),should be
[DBName] varchar(255),
In at least sys.databases, database name is of SYSNAME type, which currently equates to nvarchar(128) NOT NULL. While I can understand using a VARCHAR(128) if one is certain the character set strictly fits within a VARHCAR, I'm a little puzzled as to where the choice of 255 bytes comes from.