Monitoring Locking in SQL Server

SQL Server, has a specific dynamic management view (DMV) which provides detailed information regarding the active locks within the SQL Server instance that is, locks that have been already granted or they are waiting to be granted. The DMV is called: sys.dm_tran_locks.   Using the sys.dm_tran_locks DMV for Monitoring Locking in SQL Server The following … Read more…

Massively Detaching and Re-attaching Databases in SQL Server

In this article, we will be discussing about massively detaching and re-attaching databases in SQL Server.   Why massively detaching and re-attaching all the databases in a SQL Server instance? There are cases where you might need to massively detach and re-attach all the databases in a SQL Server instance. Such scenario can be a … Read more…

T-SQL Tip: Inserting Leading Characters to a String

This post, is actually a T-SQL tip, on how to easily insert leading characters to a string. The Scenario for Inserting Leading Characters Consider that  you have a fixed-length table column for which you want to add leading characters, so that all its records, values with the same number of characters. How to Insert Leading … Read more…

T-SQL Tip: Retrieving Security-Related Info for SQL Server Logins

—— Retrieves Security-Related Information— for all the SQL Server Logins—— SQL Server versions  supported: SQL Server 2005 or later—SELECT [name] as LoginName,LOGINPROPERTY ([name] , ‘DefaultDatabase’) as DefaultDatabase,LOGINPROPERTY ([name] , ‘DaysUntilExpiration’) as DaysUntilExpiration,(CASE ISNULL(LOGINPROPERTY ([name] , ‘IsExpired’),0) WHEN 0 THEN ‘False’ ELSE ‘True’ END) as IsExpired,(CASE ISNULL(LOGINPROPERTY ([name] , ‘IsLocked’),0) WHEN 0 THEN ‘False’ ELSE ‘True’ END) … Read more…

Selected Tweets of Year 2012!

Hello friends, Another year has come to an end and as being faithful to the “tradition” of posting in the last day of every year my selected tweets for the year that ends, here I am, posting the “Selected Tweets of Year 2012!“. It was another great year of interaction with you, the SQL Server Community. … Read more…

T-SQL Tip: Getting the File Locations for all DBs in a SQL Server Instance

—— Dynamically builds  T-SQL statements for retrieving the file — locations for all the databases in the SQL Server Instance—— SQL Server versions  supported: SQL Server 2005 or later—SELECT ‘use ‘+ [name]+’; select ”’+[name]+”’ as DBName,cast ([name] as varchar(45)) as LogicalFileName,cast (filename as varchar(100)) as FileName from sysfiles;’ as SQLStatement FROM master.sys.databases Details: Just execute the statements generated … Read more…

Internal Query Processor Error: The query processor could not produce a query plan

OK folks, it did happen at some point, to get this error message: Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.   Reproducing the Internal Query Processor Error Message I was trying to execute the following query: SELECT *  FROM dbo.tbl1 WHERE  tbl2ID=(SELECT … Read more…

Handling Disk Space Issues During Heavy Index Rebuild Operations

There are times where you need to massively rebuild indexes on some really large databases, after indicated by the relevant analysis of course. However, rebuilding indexes, requires also the adequate amount of free disk space that will be used during the rebuild operation (mainly for the sorting process). Usually the required space is the size of … Read more…

[Webcast] SQL Server 2012: The Database Engine

– Celebrating 250.000+ Visits! – SQL Server 2012 shipped with a plethora of useful new features. In this webcast we will see the majority of the Database Engine features. To this end, we are going to see enhancements that fall into the following SQL Server areas: High Availability Manageability Enhancements Programmability Performance & Scalability Security … Read more…

[Celebrating 250.000 Visits!] Q&A Session on SQL Server

– Celebrating 250.000+ Visits! – As promised a few days ago, the celebrations for the 250.000+ visits on my blog continue with the Q&A Session on SQL Server! You can submit your SQL Server-related questions using this form. I will be accepting questions until October 24, 2012. After the submission is over, I will categorize all … Read more…