Category Archives: T-SQL

SQL PowerShell to check and repair Ad-hoc distributed queries Vulnerability

Introduction Ad hoc distributed queries use the OPENROWSET and OPENDATASOURCE functions to connect to remote data sources that use OLE DB. As the name suggests, ad-hoc distributed queries should only be used with infrequent access to data sources. For the … Continue reading

Posted in PowerShell, Security, SQL, T-SQL, Uncategorized, Vulnerability | Tagged , , , , , | Leave a comment

Microsoft SQL Server Error 5243 – Top 3 Ways To Fix This Issue

Maintaining the SQL server database is always the first priority of the SQL administrators. But sometimes SQL database users have to face Microsoft SQL server error 5243 and error 5242. These are common errors. Due to this problem, the SQL … Continue reading

Posted in SQL, T-SQL | Tagged | Leave a comment

Overview of SQL UNION

This article will provide a deep dive into the SQL UNION operator, describing its many uses along with examples and explore some common questions like the differences between UNION vs UNION ALL. To address real-world data requirements, we may need … Continue reading

Posted in T-SQL | Tagged , , , | Leave a comment

SQL Server 2017 DMVs and DMFs for DBAs

Dynamic management views (DMVs) and dynamic management functions (DMFs) are system views and system functions that return metadata of the system state. On querying the related system objects, database administrators can understand the internals of SQL Server. It allows us to … Continue reading

Posted in SQL 2017, T-SQL | Tagged , , , , , , , | Leave a comment

Different methods to write PowerShell output to a SQL table

PowerShell has become the ultimate choice for many database administrators because of its efficient way of handling and managing automation in a simple, quick way. It’s built on .NET Framework and uses Object Models such as COM, ADSI, ADO, and … Continue reading

Posted in PowerShell, SQL, T-SQL | Tagged , , , , , | 2 Comments

Monitoring SQL Server database status changes using T-SQL and PowerShell scripts

Monitoring a SQL Server database is a critical component of database administration. Ninety percent of the organizations expect the number of databases to increase over the next twelve months. An increase in data volumes can have negative effects on the … Continue reading

Posted in SQL, T-SQL, XML | Tagged , , , | Leave a comment

SQL Server DB Migration – Cloning a database to another collation

Database migration is a vital task in any environment, complex or otherwise. Seamless migrations are the goal but the efforts required to ensure it are tremendous. A global SQL Server Collation Sequence update is the answer to the puzzle, but … Continue reading

Posted in SQL, T-SQL | Tagged , , | Leave a comment

How to Capture Database(s) usage stats using sp_spaceused and PowerShell

The objective of this article is to look at the possible ways of capturing database usage trends using the most commonly available tools and techniques. The integration of SQL, the use of sp_spaceused, and the flexibility offered by PowerShell have … Continue reading

Posted in JSON, SQL, SQL 2012, SQL 2016, T-SQL | Tagged , , , , | Leave a comment

How to analyze SQL Server database performance using T-SQL

The performance of a database is the most challenging and critical part of database optimization. The challenge every DBA faces is to identify the most resource-intensive databases. This article talks about the natively available features that can accomplish the task of … Continue reading

Posted in SQL Server 2017, sysfiles, T-SQL | Leave a comment

SQL Server 2016 enhancements – Truncate Table and Table Partitioning

The idea behind this article is to discuss the importance and the implication of SQL Partition and understand the truncate command partitioning enhancements in SQL 2016 One of the biggest challenges for a DBA is to identify the right candidate … Continue reading

Posted in SQL 2016, T-SQL | Tagged , , , , | Leave a comment