The Multifunctioning DBA

Dec 3 2010   9:07PM GMT

Powershell SMO database size property incorrect

Colin Smith Colin Smith Profile: Colin Smith

Ran into an issue while writing a script to gather database properties via smo and one that I want is database size. I wrote the script and started testing it and my values were all wrong and the same for all databases in the instance. I did a few things trying to figure out what I was doing wrong and I even pinged Aaron Nelson (Blog | Twitter) about the issue and he was nice enough to help me out and take a look at the issue. He looked at the code and my results and had me check in SSMS that the results were correct. After I checked in SSMS and verified that the values were in fact correct he had me try getting the data using the provider, explained here in his Hey Scripting Guy article. I did that and now the data was correct. That is strange and I started thinking and I had not attempted to run this script from another host. I did that and I saw that, using SMO, the data came back was correct. Now I knew it was something with my machine but what?

I started searching and I found it. This is a bug in SQL Server 2008 SP1. I have a SQL 2008 instance running on my machine that I use for testing and developing and I had recently applied SP1. Here is a link to the article about the bug. I downloaded and applied CU3 for 2008 SP1 and now I am getting the correct results. What a pain. I am just glad that it is working again and it was not my code.

Big thanks to Aaron Nelson (Blog | Twitter) for taking the time to help me out. I really appreciate it.

Hope this helps

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: