Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Basit's SQL Server Tips

Basit Farooq is a Lead Database Administrator, Trainer and Technical Author. He has more than a decade of IT experience in development, technical training and database administration on Microsoft SQL Server platforms. Basit has authored numerous SQL Server technical articles, and developed and implemented many successful database infrastructure, data warehouse and business intelligence projects. He holds a master's degree in computer science from London Metropolitan University, and industry standard certifications from Microsoft, Sun, Cisco, Brainbench, Prosoft and APM, including MCITP Database Administrator 2008, MCITP Database Administrator 2005, MCDBA SQL Server 2000 and MCTS .NET Framework 2.0 Web Applications.

Changing SQL Server Agent Jobs Ownership: Who should own SQL Server Agent Jobs

I writing this blog post as a result of the following two questions, which I’ve been asked by one of my blog follower recently.

  • Question#1: Does it matter who is the owner of the SQL Server Agent job?
  • Question#2: Is there a way to quickly update the job owner for…

Read more

0 comments, 147 reads

Posted in Basit's SQL Server Tips on 4 April 2014

Availability databases in unhealthy data synchronization state (Error: 35285, Severity: 16, State: 1.)

After power surge last night, I realized few availability databases (also known as a “database replica”) have an unhealthy data synchronization state. What I mean from unhealthy is that they have a status of “Not Synchronizing” in SQL Server Management Studio for both primary and all secondary availability group replicas… Read more

0 comments, 249 reads

Posted in Basit's SQL Server Tips on 2 April 2014

Verify a success of database backups

One of the most important tasks on a DBA’s to-do list is backing up databases on a regular basis. This is because reliable backups are the most important tool in ensuring data recovery. Therefore, it is important for the DBA to check for database backups and validate that they have… Read more

7 comments, 166 reads

Posted in Basit's SQL Server Tips on 16 March 2014

Tables without Clustered Indexes?

Today, we experienced performance issues with some of the SSRS reports that were deployed as part of the latest application/database release. While investigating this performance problem, I realized that the underlying tables for these report queries do not have clustered index. I was even more surprised when I realized that… Read more

7 comments, 550 reads

Posted in Basit's SQL Server Tips on 13 March 2014

Different approaches of counting number of rows in a table

Today, I received an email from the developer asking if there is a better way instead of the COUNT (*) Transact-SQL statement, to count the number of records in a table. My reply to his question is yes, there are several methods to get this information from SQL Server. However,… Read more

7 comments, 169 reads

Posted in Basit's SQL Server Tips on 6 March 2014

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 on fragmentation. However, sometimes we may need to rebuild all indexes on all tables in… Read more

2 comments, 248 reads

Posted in Basit's SQL Server Tips on 23 February 2014

Removing part of string before and after specific character using Transact-SQL string functions

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 example, if the table contains the full names of the people in the format… Read more

0 comments, 147 reads

Posted in Basit's SQL Server Tips on 23 February 2014

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 [index_name]
      ,i.[type_desc] AS [index_type]
      ,ps.[name] AS [partition_scheme]
      ,pf.[name] AS [partition_function]
      ,p.[partition_number]
      ,r.[value] AS [current_partition_range_boundary_value]
      ,p.[rows] AS [partition_rows]
      ,p.[data_compression_desc]
FROM sys.tables t
INNER JOIN…

Read more

0 comments, 400 reads

Posted in Basit's SQL Server Tips on 17 February 2014

Get performance statistics for queries and query plans that are cached by SQL Server for faster query execution

You can use the following two DMVs to give you that information:

  • sys.dm_exec_cached_plans – You can use this dynamic management view to see information about the plans that are cached by SQL Server, along with other information such as cached query text, the amount of memory taken by cached plans,…

Read more

0 comments, 153 reads

Posted in Basit's SQL Server Tips on 17 February 2014

Transact-SQL (T-SQL) query to return the status and detail information for all SQL Server Full-Text Catalogs on an SQL Server instance

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 catalogs, to ensure that all full-text catalogs are successfully populated without errors. However, to check… Read more

0 comments, 239 reads

Posted in Basit's SQL Server Tips on 27 January 2014

Get SQL Server Physical Cores, Physical and Virtual CPUs, and Processor type information using Transact-SQL (T-SQL) script

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 by SQL Server:

  • Total number of physical CPUs
  • Total number of physical cores…

Read more

1 comments, 274 reads

Posted in Basit's SQL Server Tips on 22 January 2014

Cumulative Update # 8 for SQL Server 2012 Service Pack 1 is now available!

The 8th cumulative update (CU8) for SQL Server 2012 Service Pack 1 is now available for download at the Microsoft site here.

CU8 contains all the SQL Server 2012 SP1 hotfixes which have been available since the initial release of SQL Server 2012 SP1.


Read more

0 comments, 173 reads

Posted in Basit's SQL Server Tips on 22 January 2014

Monitor availability groups and availability replicas status information using T-SQL

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]
		,dr.[synchronization_state_desc]
		,dr.[suspend_reason_desc]
		,dr.[synchronization_health_desc]
		,dr.[replica_id]
		,ar.[availability_mode_desc]
		,ar.[primary_role_allow_connections_desc]
		,ar.[secondary_role_allow_connections_desc]
		,ar.[failover_mode_desc]
		,ar.[endpoint_url]
		,ar.[owner_sid]
		,ar.[create_date]
		,ar.[modify_date]
		,dr.[recovery_lsn]
		,dr.[truncation_lsn]
		,dr.[last_sent_lsn]
		,dr.[last_sent_time]
		,dr.[last_received_lsn]
		,dr.[last_received_time]
		,dr.[last_hardened_lsn]
		,dr.[last_hardened_time]
		,dr.[last_redone_lsn]
		,dr.[last_redone_time]…

Read more

0 comments, 124 reads

Posted in Basit's SQL Server Tips on 20 January 2014

SQL Server monitoring and optimization

To optimize the performance of your database, you need to monitor and tune. You determine the performance baseline, how SQL Server is currently performing, through monitoring. Your optimization process includes making changes and then monitoring their effect. This means adjusting two overlapping performance areas, that is, database server performance and… Read more

0 comments, 192 reads

Posted in Basit's SQL Server Tips on 18 December 2013

Nine T-SQL best practices

SQL Server databases are the backbone of many enterprise applications, and good Transact-SQL (T-SQL) code is the best way to maximize SQL Server performance. Therefore, it is important for SQL developers to follow T-SQL best practices and guidelines when writing code. This article highlights some common T-SQL best practices to… Read more

2 comments, 351 reads

Posted in Basit's SQL Server Tips on 16 December 2013

How to work around Azure database migration limitations

Microsoft Windows Azure SQL Database, commonly known as SQL Azure, is a relational database in the cloud that is part of the Windows Azure platform. Although Windows Azure SQL Database is built on the SQL Server platform, there are differences you should consider when performing an Azure SQL Database migration. Read more

0 comments, 198 reads

Posted in Basit's SQL Server Tips on 14 December 2013

Understanding SQL Server Query Optimization – Part 3

A critical part of database design and management is index design. Index design involves balancing space requirements and the resource overhead required to keep indexes up-to-date compared to the performance improvements resulting from the indexes. You can either use dynamic management functions (DMFs) and views (DMVs) or Database Engine Tuning… Read more

0 comments, 175 reads

Posted in Basit's SQL Server Tips on 14 December 2013

Understanding SQL Server Query Optimization – Part 2

An execution plan is the sequence of operations SQL Server query optimizer performs to run the statements. The SQL Server query optimizer creates an execution plan before it actually runs a query. As per Microsoft Book Online, “Execution plans graphically display the data retrieval methods chosen by the SQL Server… Read more

0 comments, 175 reads

Posted in Basit's SQL Server Tips on 14 December 2013

SQL Server Encryption Options

Many database servers store confidential data, which must be protected from unauthorized access when it’s transmitted across the network and stored on the server. SQL Server provides support for encrypted connections, encrypting data, encrypting database and for encrypted storage.

Click here to read full article on SSWUG.org


Read more

0 comments, 192 reads

Posted in Basit's SQL Server Tips on 14 December 2013

Bulk Transfers: Some guidelines

Bulk transfers are a common way of importing large amounts of data into, or exporting large amounts of data out of, SQL Server databases.  SQL Server supports bulk transfers run from an operating system command line or the SQL Server command processor. When performing bulk transfers, you must consider the… Read more

0 comments, 172 reads

Posted in Basit's SQL Server Tips on 14 December 2013

Older posts