Freitag, 3. Juni 2011

SQL Server Tools

This post contains some Powershell scripts to quick check some things on a running SQL Server instance. Imagine you got a SQL server delivered by a data centre team and now you are responsible for installing a software that shall use this server.
Before looking in all the various bugs in your delivered software, it is a good idea to check if SQL server was installed and prepared properly. Usually you have some credentials and a server address. So a little tool that checks if instance can be reached with this data would be nice.
Script you can find at [1] does exactly that. Just replace vars with your server's data (hostname, port, credentials). It also retrieves exact version with which you can check if correct patch level was installed (see Microsoft's info at [3]).
Another fancy thing would be to check which databases or roles are available with your user. This can be done using a nice object called Microsoft.SqlServer.Management.SMO.Server . Just google for this object to learn more. A script that retrieves databases, roles and some other interesting infos can be found at [4]. A much more extense example can be found at [5])


References
[1] UserConnectionTest.ps1
https://connectionteste.svn.sourceforge.net/svnroot/connectionteste/SQLTools/UserConnectionTest.ps1
[2] SQL Server Connection String Parameter
http://www.connectionstrings.com/Articles/Show/all-sql-server-connection-string-keywords
[3] SQL Version
http://support.microsoft.com/kb/321185
[4] GetSQLUserRoles.ps1
https://connectionteste.svn.sourceforge.net/svnroot/connectionteste/SQLTools/GetSQLUserRoles.ps1
[5] Lots of SQL Server instance details
http://mspowershell.blogspot.com/2009/12/most-dbas-have-had-to-examine-unknown.html

Dig and Cygwin

Just a quick tip today. If you need dig, a handy DNS query tool, on your cygwin bash you have to install bind package. Searching for Dig in cygwin's setup tool does not help, so after I figured out it is part of BIND I thought I help save some time ;)
Bind is a full blown DNS server but it's not that big to install and dig is definitly worth it ;)