- Date: 2017-09-29 Editor: Byzqy
This article records several T-SQL statements that query database information:
- View database Information
- View server name
- View instance Name
Files: Sqlquery2.sql
/*Description: Sqlquery2.sql (This is a new query in SQL Server Management Studio) OS name: Microsoft Windows 7 Environment: Microsoft SQL Server 2012 tools: Mi Crosoft SQL Server Management Studio*/--Global Variables View database informationPrint 'name of the server:'+@ @SERVERNAMEPrint 'version of SQL Server:'+@ @VERSIONSelect @ @SERVERNAME as 'Server name'Select @ @VERSION as 'version of SQL Server'--Querying all database informationsp_helpdb--See if the server name and instance name are consistentSelect @ @SERVERNAME asServer name, SERVERPROPERTY ('servername') asInstance Name--An instance name a server nameSelect @ @SERVERNAME SelectSERVERPROPERTY ('servername')
View Code
:
01
02
03
04
--the End.
Sqlserver_query2_ View Database Information | View server name | View instance Name