![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to read sql server database properties hi, I have an requirement wherein I need to report the following properties of the database 1. The database size of the Onepoint database 2. The autogrowth Properties viz., File Growth and Maximum File Size. Does anybody has any idea on how to go about this. Thanks, Aditya |
My System Specs![]() |
| | #2 (permalink) |
| | RE: How to read sql server database properties This information is a bit scatter but we can find it like this. This is written using SQL SERVER 2005 # load SMO assemblies ## use $null to prevent display of assembly load information $null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") $null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") $null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") clear-host ## set SMO variable $Server = new-object Microsoft.SqlServer.Management.Smo.Server("server-name") $db = $server.databases Write-Host "AdventureWorks database" Write-Host "Database size = " $db["AdventureWorks"].Size Write-Host "File Information" $db["AdventureWorks"].Filegroups["PRIMARY"].Files Load the SMO assemblies. Connect to the server object & pick off the database you are interested in. The size is a direct property. The autogrowth you need to look in filegroups and then at the files. If you have more than one file group you will need to loop throught them. The max file size in reported in KB and -1 means unlimited growth -- Richard Siddaway All scripts are supplied "as is" and with no warranty PowerShell MVP Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "AdityaKir" wrote: Quote: > hi, > > I have an requirement wherein I need to report the following properties of > the database > > 1. The database size of the Onepoint database > 2. The autogrowth Properties viz., File Growth and Maximum File Size. > > Does anybody has any idea on how to go about this. > > Thanks, > > Aditya |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Can VBScript read foxpro 2.6 database? | VB Script | |||
| How to retrieve the extended Properties of a database | PowerShell | |||
| Read txt file and compare to database | VB Script | |||
| How to force a database recovery + recovered properties bug | Live Mail | |||
| interesting read> media player database | Vista General | |||