What is TSQL2sday? Two years ago, Adam Machanic (blog | twitter) had this brilliant idea for a monthly SQL Server blogger event (the origin of TSQL2sday). This month’s event is hosted by Brad Schulz (blog) and the selected topic is “Prox ‘n’ Funx” (aka Procedures and Functions).
Today, I’m sharing my favorite SQL Server metadata function – SERVERPROPERTY(‘propertyname’). This handy function has been around since at least SQL Server 2000. If you need to get a quick “report” of the high level configuration information about your SQL Server instance – this is the function to use. Of course, with each new version of SQL Server it is subject to change, so always check usage in BOL (this link is to SQL 2008 R2 Books Online, but you can get to other versions from there).
If a property isn’t valid for a particular version of SQL Server (or if you just flat out typo the property name!), then NULL will be returned. Here’s a sample query for you to try out.
And if you need database property info – guess what? There are DATABASEPROPERTY and DATABASEPROPERTYEX functions you should check out! Until next time – happy TSQL2sday!