Top 10 Transact-SQL Statements a SQL Server DBA Should Know

SQL Server of Microsoft product is a DBMS with several features. Database administrators can’t catch pace with the massive number of Statements in T-SQL and syntax required to extract data from the SQL Server. Every SQL Server feature does have its own set of queries, and one blog can't possibly cover them all. Learn how to implement, configure, maintain, and perform various critical operations on SQL Server from this SQL server dba training available online. Experience various real-time use cases from the industry experts through this course that aids in your professional career development.

 

The top ten T-SQL commands for the SQL Server DBAs are included in this blog. The following are the four types of Statements in T-SQL that are addressed in this blog:

Statements in Transact-SQL at the backup level should be familiar to SQL Server DBAs

Statement 1 in T-SQL

Using the present SQL Server connection, the T-SQL query gathers information like the name of the current instance, Hostname, ServicePack, Server type, version number, and Edition. The 'Edition' will inform you if your SQL Server is 64-bit or 32-bit, and 'Productlevel' will inform you which service pack is running on your SQL Server? This also shows you if the SQL Server you're working with is clustered. Refer to Fig-1.1.

Statement 2 in T-SQL

A few SQL Server's capabilities and performance are governed by server-level settings. A DBA for SQL Server should also be aware of configuration at the server level data. The SQL statement below will provide you all the details you need about server settings. Refer to Fig-1.2.

 

Statement 3 in T-SQL

A database administrator must be aware of the importance of security. It's also crucial to know whether logins have a security admin role or a server-level administrator. The SQL command below will provide information about the system admin server and security admin roles. Refer to Fig-1.3.

Statement 4 in T-SQL

As a database administrator, you should also be aware of all traces which are enabled. The T-SQL query below lists all trace flags which are globally enabled on a server. Refer to Fig-1.4.

The below T-SQL query displays all trace flags set on the present connection to a SQL server. Refer to Fig-1.4.

Transact-SQL queries at the database level should be familiar to SQL Server DBAs

Statement 5 in T-SQL

Getting information at the database level is just as crucial as getting information at the server level. The below T-SQL query displays information about the databases' names, compatibility levels, recovery models, and ongoing status. The outcome of this statement in T-SQL will assist you in determining ff any updates to the compatibility level are necessary. The database's compatibility level might not be at the expected level when upgrading from an earlier version to a new one. The statement below will assist you to get a list of all compatible database names. It also shows the database's online/offline state and assists the DBA in determining whether the recovery model needs to be updated. Refer to Fig-1.5.

If SQL Server 2000 is being used, you may use the Statement in T-SQL as shown below. Refer to Fig-1.6.

Statement 6 in T-SQL 

The database location is the next level for database-related information that is required. The physical location and logical name of all the log/data files accessible in the present instance of SQL Server are provided by the following T-SQL Statement. Refer to Fig-1.7.

If SQL Server 2000 is being used, you may use the Statement in T-SQL as shown below. Refer to Fig-1.8.

Statement 7 in T-SQL

Other filegroups besides the principal filegroup may exist in a database. The below T-SQL query runs in every server's database and presents the results of the filegroups. Refer to Fig-1.9.

SQL Server DBAs should be familiar with Transact-SQL statements at the backup level

Statement 8 in T-SQL

Database backups are database administrators' butter and bread. The below T-SQL query reveals all the server's databases, and also the date on which the previous backup occurred. Database administrators will be able to check backup jobs more easily as a result of this and ensuring that backups are performed for all databases. Refer to Fig-1.10.

Statement 9 in T-SQL

The information at the next level that the SQL Server DBA should be aware of is all backup files' location. You do not need backups to be saved to an Operating System or local drive. The T-SQL query below queries the msdb database for all information about the ongoing location of the backup. Refer to Fig-1.11.

A DBA for SQL Server must be familiar with the following Transact-SQL statements at the process level

Statement 10 in T-SQL

Finally, but certainly not least, there is information on ongoing processes and also information about connections. SQL Server DBA has used sp_who2 and sp_who to verify the present users, processes, and sessions since the beginning. These queries also included details on the sessions' blocking, memory, and CPU. Refer to Fig-1.12. Besides, look up sp_who3 on the internet. Numerous posts on sp_who3 may be found online.

Conclusion

Microsoft SQL Server, as stated at the outset of this post, is a DBMS with rich features. SQL Server consists of its own list of commands for each function it supports. The Top 10 T-SQL statements for SQL Server DBAs were reviewed in this post.

Share
LEAVE A REPLY
Related Post
COMMENTS
  1. author
    27 Aug 2019
    Tomas Mandy

    Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius

    1. author
      27 Aug 2019
      Britney Millner

      Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius

  2. author
    27 Aug 2019
    Simon Downey

    Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius