Stored Procedures Archives - {coding}Sight https://codingsight.com/category/database-development/stored-procedures/ Blog for SQL Server DBAs and Developers Mon, 07 Aug 2023 08:58:34 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 https://codingsight.com/wp-content/uploads/2021/10/cropped-Soсial_-Fb_180х180-1-32x32.png Stored Procedures Archives - {coding}Sight https://codingsight.com/category/database-development/stored-procedures/ 32 32 Stored Procedure to Get Logins and Server Roles Inventory https://codingsight.com/stored-procedure-to-get-logins-and-server-roles-inventory/ Fri, 18 Mar 2022 17:44:11 +0000 http://codingsight.com/?p=17171 Security is for sure one of the most important areas that we, as professional DBAs, must cover. Within SQL Server, there are many ramifications that can derive from the security topic itself. In this article, I want to focus on an entry-level security topic that covers something very basic. To continue with my series of …

The post Stored Procedure to Get Logins and Server Roles Inventory appeared first on {coding}Sight.

]]>
How to Get Tables Information in SQL Server via Stored Procedure https://codingsight.com/sp-to-get-database-sql-tables-information/ Thu, 19 Aug 2021 08:30:28 +0000 http://codingsight.com/?p=16268 As a database administrator, developer, or data analyst, understanding the structure and details of your SQL Server database tables is crucial. It aids in optimizing performance, debugging issues, and making informed decisions about data management. In this post, we will delve into the practical steps of using stored procedures to retrieve tables information in SQL …

The post How to Get Tables Information in SQL Server via Stored Procedure appeared first on {coding}Sight.

]]>
How to Show List of Indexes in SQL Server using Stored Procedure https://codingsight.com/stored-procedure-to-get-indexes-status-in-all-databases/ Mon, 16 Aug 2021 08:54:37 +0000 http://codingsight.com/?p=16134 As SQL Server DBAs, we’ve heard that index structures can dramatically improve the performance of any given query (or set of queries). Still, there are certain details that many DBAs overlook, like the following: It’s very important to keep in mind that the system view that holds this particular metadata gets wiped every time the …

The post How to Show List of Indexes in SQL Server using Stored Procedure appeared first on {coding}Sight.

]]>
How to Use the sp_whoisactive PowerShell Script for Real-Time SQL Server Monitoring https://codingsight.com/using-sp_whoisactive-in-sql-server/ Fri, 30 Jul 2021 13:17:22 +0000 http://codingsight.com/?p=15345 Nowadays, within the SQL Server DBA community, it is extremely likely that we use, or at the very least have heard of, the famous stored procedure sp_WhoIsActive developed by Adam Machanic. During my time as a DBA, I used the SP to immediately check what’s going on inside a particular SQL Server instance when it …

The post How to Use the sp_whoisactive PowerShell Script for Real-Time SQL Server Monitoring appeared first on {coding}Sight.

]]>
How to Get SQL Server Statistics Information Using System Statistical Functions https://codingsight.com/get-sql-server-statistics-information-using-system-statistical-functions/ Thu, 15 Jul 2021 11:05:34 +0000 http://codingsight.com/?p=15281 Often, we need to gather system statistics regarding running SQL Server Instances, such as the number of total connections attempted to SQL Server instance since its start, or the time that SQL Server spent in active operations, etc. Microsoft brought us a separate set of system functions to retrieve the system-related statistics.  Today, I am …

The post How to Get SQL Server Statistics Information Using System Statistical Functions appeared first on {coding}Sight.

]]>
SQL Server RAISERROR Statement with Simple Examples https://codingsight.com/sql-raiserror-statement-with-simple-examples/ Wed, 14 Jul 2021 13:11:08 +0000 http://codingsight.com/?p=15299 The SQL RAISERROR statement is used to send a custom message to the client application. It also can be used to debug the application and applies to the error handling mechanism. SQL RAISERROR Statement Syntax and Parameters The syntax of the SQL RAISERROR statement is the following: Below you can see the explanation of the …

The post SQL Server RAISERROR Statement with Simple Examples appeared first on {coding}Sight.

]]>
Stored Procedure to Delete Duplicate Records in SQL Table https://codingsight.com/how-to-delete-duplicate-records-in-a-table/ Wed, 14 Jul 2021 11:32:39 +0000 http://codingsight.com/?p=15328 Sometimes during our run as DBAs, we come up across at least one table that is loaded with duplicate records. Even if the table has a Primary Key (an auto-incremental one in most cases), the rest of the fields might have duplicate values. However, SQL Server allows for many ways to get rid of those …

The post Stored Procedure to Delete Duplicate Records in SQL Table appeared first on {coding}Sight.

]]>
How to Find SQL Server Instance Name and More with Stored Procedures https://codingsight.com/stored-procedure-to-get-instance-settings/ Thu, 10 Jun 2021 11:01:01 +0000 http://codingsight.com/?p=14574 SQL Server instances serve as the backbone of a business model, housing databases that contain vital data for backend operations or specific application configurations. Each instance possesses a unique set of values or settings that, when properly tuned, align with industry best practices. In this article, we delve into the functionality of a particular Stored …

The post How to Find SQL Server Instance Name and More with Stored Procedures appeared first on {coding}Sight.

]]>
Execute Dynamic Query in SQL Server https://codingsight.com/dynamic-sql-execution-in-sql-server/ Wed, 09 Jun 2021 07:56:52 +0000 http://codingsight.com/?p=14536 Dynamic SQL is a statement constructed and executed at runtime, usually containing dynamically generated SQL string parts, input parameters, or both. Various methods are available to construct and run dynamically generated SQL commands. The current article is going to explore them, define their positive and negative aspects, and demonstrate practical approaches to optimize queries in …

The post Execute Dynamic Query in SQL Server appeared first on {coding}Sight.

]]>
How to Get Backup Status in SQL Server using Stored Procedure https://codingsight.com/a-dedicated-stored-procedure-to-get-the-latest-database-backup-status/ Fri, 21 May 2021 07:08:27 +0000 http://codingsight.com/?p=14000 Any SQL Server DBA (of course, this applies to all platforms) will agree that database backups are the most essential things for data professionals. Monitoring those backups’ statuses is crucial. To make this task more straightforward, I have created a custom Stored Procedure. It will allow you to get the latest database backups’ (if any) …

The post How to Get Backup Status in SQL Server using Stored Procedure appeared first on {coding}Sight.

]]>