Today, I was working on a new script that would collect database’s file size and store them in a central repository, I have to use linked servers, some dynamic sql, and while loops. After spending time breaking down and going thru some trails and errors, it worked nicely until I encountered an error:
Msg 7313, Level 16, State 1, Line 2
An invalid schema or catalog was specified for the provider “SQLNCLI10″ for linked server “VipA\InstanceA”.
So after spending 20 some minutes scratching my head as to why this database is giving me grief, I found out the reason: In the first few weeks of my current job, I found that one of the databases had a trailing white space. I have asked around and no one would give me an answer.
This shit really piss me off, of all the 270 databases, this is the ONLY bloody database with a white space AND it screws up my code. I want to so BADLY right this wrong but I’m not sure what kind of impact it would have.
To solved this, I simply put [ ] around the variable @dbname.