With the below T-SQL script, you can get basic SQL Server instance info such as:
- Full instance name
- SQL Server version
- Edition
- Collation
- Number of databases
- Product level (i.e. SP-level)
- …and more
The T-SQL Script
The script uses the built-in SQL Server function SERVERPROPERTY.
SELECT SERVERPROPERTY('ServerName') AS FullInstanceName, REPLACE(SUBSTRING(@@version,0,CHARINDEX('-',@@version)),'Microsoft ','') as FullSQLVersion, SERVERPROPERTY('ProductVersion') AS ProductVersion, SERVERPROPERTY('ProductLevel') AS ProductLevel, SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS ComputerNamePhysicalNetBIOS, SERVERPROPERTY('MachineName') AS MachineName, SERVERPROPERTY('InstanceName') as InstanceName, SERVERPROPERTY('BuildClrVersion') AS BuildClrVersion, SERVERPROPERTY('Collation') AS Collation, SERVERPROPERTY ('edition') as InstanceEdition, CASE WHEN SERVERPROPERTY('EngineEdition')=1 THEN 'Personal/Desktop' WHEN SERVERPROPERTY('EngineEdition')=2 THEN 'Standard' WHEN SERVERPROPERTY('EngineEdition')=3 THEN 'Enterprise' WHEN SERVERPROPERTY('EngineEdition')=4 THEN 'Express' WHEN SERVERPROPERTY('EngineEdition')=5 THEN 'SQL Database' WHEN SERVERPROPERTY('EngineEdition')=6 THEN 'SQL Data Warehouse' END AS EngineEdition, CASE WHEN SERVERPROPERTY('IsClustered')=1 THEN 'Clustered' WHEN SERVERPROPERTY('IsClustered')=0 THEN 'Not Clustered' ELSE 'N/A' END AS ClusteredStatus, (SELECT COUNT(*) FROM sys.databases) AS TotalDatabases
For more information about the built-in SQL Server function SERVERPROPERTY please visit this MSDN article.
Strengthen your SQL Server Administration Skills – Enroll to our Online Course!
Check our online course on Udemy titled “Essential SQL Server Administration Tips”
(special limited-time discount included in link).
Via the course, you will learn essential hands-on SQL Server Administration tips on SQL Server maintenance, security, performance, integration, error handling and more. Many live demonstrations and downloadable resources included!
Learn essential SQL Server Development Tips! Enroll to our Online Course!
Check our online course titled “Essential SQL Server Development Tips for SQL Developers”
(special limited-time discount included in link).Sharpen your SQL Server database programming skills via a large set of tips on T-SQL and database development techniques. The course, among other, features over than 30 live demonstrations!
Recommended Online Courses:
- SQL Server 2022: What’s New – New and Enhanced Features
- Introduction to Azure Database for MySQL
- Working with Python on Windows and SQL Server Databases
- Boost SQL Server Database Performance with In-Memory OLTP
- Introduction to Azure SQL Database for Beginners
- Essential SQL Server Administration Tips
- SQL Server Fundamentals – SQL Database for Beginners
- Essential SQL Server Development Tips for SQL Developers
- Introduction to Computer Programming for Beginners
- .NET Programming for Beginners – Windows Forms with C#
- SQL Server 2019: What’s New – New and Enhanced Features
- Entity Framework: Getting Started – Complete Beginners Guide
- A Guide on How to Start and Monetize a Successful Blog
- Data Management for Beginners – Main Principles
Related SQL Server Administration Articles:
- Essential SQL Sever Administration Tips
- How to Patch a Standalone SQL Server Instance
- The SQL Server Browser Service and UDP Port 1434
- The Maximum Number of Concurrent Connections Setting in SQL Server
- Top 10 SQL Server DBA Daily Tasks List
- There is no SQL Server Failover Cluster Available to Join
- Encrypting a SQL Server Database Backup
- Script that Returns SQL Server’s Version Name
- …more
Recommended Software Tools
Snippets Generator: Create and modify T-SQL snippets for use in SQL Management Studio, fast, easy and efficiently.
Dynamic SQL Generator: Convert static T-SQL code to dynamic and vice versa, easily and fast.
Get Started with Programming Fast and Easy – Enroll to the Online Course!
Check our online course “Introduction to Computer Programming for Beginners”
(special limited-time discount included in link).Learn the philosophy and main principles of Computer Programming and get introduced to C, C++, C#, Python, Java and SQL.
Subscribe to our newsletter and stay up to date!
Subscribe to our YouTube channel (SQLNetHub TV)
Easily generate snippets with Snippets Generator!
Secure your databases using DBA Security Advisor!
Generate dynamic T-SQL scripts with Dynamic SQL Generator!
Check our latest software releases!
Check our eBooks!
Rate this article:
Reference: SQLNetHub.com (https://www.sqlnethub.com)
© SQLNetHub
Artemakis Artemiou is a seasoned Senior Database and AI/Automation Architect with over 20 years of expertise in the IT industry. As a Certified Database, Cloud, and AI professional, he has been recognized as a thought leader, earning the prestigious Microsoft Data Platform MVP title for nine consecutive years (2009-2018). Driven by a passion for simplifying complex topics, Artemakis shares his expertise through articles, online courses, and speaking engagements. He empowers professionals around the globe to excel in Databases, Cloud, AI, Automation, and Software Development. Committed to innovation and education, Artemakis strives to make technology accessible and impactful for everyone.