Quantcast
Channel: Basit's SQL Server Tips » SQL Scripts
Browsing all 17 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Determine space used for each table in a SQL Server database

I have written following Microsoft SQL Server T-SQL scirpt to quickly determine space used for each table in a SQL Server database. This script returns following information for each table in the...

View Article



Image may be NSFW.
Clik here to view.

View SQL Server information using Transact-SQL script

Recently one of our clients requested information about their SQL Server infrastructure which we manage. In order to complete this task, I’ve written the following Transact-SQL script to retrieve...

View Article

Image may be NSFW.
Clik here to view.

Find the size of Index in SQL Server

As we know, sp_spaceused gives the size of table and index but it gives the sum of size of all indexes on a table. What if you need to capture size of individual index on a table? Thats where the...

View Article

Image may be NSFW.
Clik here to view.

Transact-SQL Script to Monitor Replication Status

Today, I’ve written the following T-SQL script which you can use to monitor the status of transactional replication and performance of publications and subscriptions. This script helps you to answer...

View Article

Image may be NSFW.
Clik here to view.

How to find SQL Agent Jobs without Notification Operator Configured?

We can either use SQL Server Management Studio or use Transact-SQL query to find any SQL Agent jobs that have been setup without notification operator. The following are the steps to find SQL Agent...

View Article


Image may be NSFW.
Clik here to view.

How to list all CLR objects inside your database?

I wrote the following query that returns the list of all CLR functions/procedures/objects exists inside your database: SELECT o.object_id AS [Object_ID] ,schema_name(o.schema_id) + '.' + o.[name] AS...

View Article

Image may be NSFW.
Clik here to view.

Find failed SQL Agent jobs using Transact-SQL script

Today, I’m sharing the following T-SQL script which you can use to find which SQL Server Agent Jobs failed yesterday. I use this script as part of my daily server monitoring SSIS package, which...

View Article

Image may be NSFW.
Clik here to view.

SQL Server Guest User – Still a Serious Security Threat

One of the security recommendation inside SQL Server Security Best Practice white paper for guest user is that, to disable guest access in every database (expect “master”, “msdb” and “tempdb”) on SQL...

View Article


Image may be NSFW.
Clik here to view.

Find missing indexes using SQL Servers index related DMVs

Today, we experienced performance issues with few databases that are hosted on one of our most critical production SQL Server. Upon reviewing the query execution plan and querying index related dynamic...

View Article


Image may be NSFW.
Clik here to view.

SQL Server DMV: sys.dm_exec_requests

Today, I’ve received an email from friend asking that that is there any way to find out the progress of following operation using T- SQL query. As we know, with the release of SQL Server 2005,...

View Article

Image may be NSFW.
Clik here to view.

Monitor availability groups and availability replicas status information...

Just a quick blog post to share a query, which I wrote to monitor availability groups and replicas and the associated databases: WITH [AvailabilityGroupReplicaCTE] AS ( SELECT dc.[database_name]...

View Article

Image may be NSFW.
Clik here to view.

Get SQL Server Physical Cores, Physical and Virtual CPUs, and Processor type...

Today, I received email from one of my blog follower asking if there is any DMV or SQL script, which he can use to find the following information about the processors that are available to and consumed...

View Article

Image may be NSFW.
Clik here to view.

Transact-SQL (T-SQL) query to return the status and detail information for...

We have about 200 user databases in which we have the full-text search enabled and these databases contain several tables. As part of my daily checks, I have to check the status of all full-text...

View Article


Image may be NSFW.
Clik here to view.

Transact-SQL query to obtain basic information about partitioned tables

Here is the simple query that returns basic information about all tables in a database that are partitioned: SELECT SCHEMA_NAME([schema_id]) AS [schema_name] ,t.[name] AS [table_name] ,i.[name] AS...

View Article

Image may be NSFW.
Clik here to view.

Removing part of string before and after specific character using...

Problem Today, one of the developers come to me and asked me the question that is there any T-SQL function that he could use to remove everything before and after a specific character in string. For...

View Article


Image may be NSFW.
Clik here to view.

Rebuild all indexes on all tables in the SQL Server database

One of the key tasks of a DBA is to maintain the database indexes and make sure they are not fragmented. You can use a sys.dm_db_index_physical_stats in a script to rebuild or reorganize indexes based...

View Article

Image may be NSFW.
Clik here to view.

The database principal owns a schema in the database, and cannot be dropped

Problem You are trying to drop a database user, but are getting the following error message: The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error:...

View Article

Browsing all 17 articles
Browse latest View live




Latest Images