By Feodor, on July 15th, 2010%
Note: Do not disable parallelism before understanding the mechanics of it and before testing the query performance. There are several ways to control the parallel execution of queries, i.e. you can use a hint within the query (OPTION(MAXDOP 1)), or you can set the “Cost threshold for parallelism” on the server level. Also, there is an . . . → Read More: How to interpret parallelism on your SQL Server
By sibir1us, on June 14th, 2010%
This script lists all objects in the database, which contain ‘select *’.
?View Code TSQLSELECT DISTINCT o.name AS ObjectName,
CASE o.xtype
WHEN ‘C’ THEN ‘CHECK constraint’
WHEN ‘D’ THEN ‘Default or DEFAULT constraint’
WHEN ‘F’ THEN ‘FOREIGN KEY constraint’
WHEN ‘FN’ THEN ‘Scalar function’
WHEN ‘IF’ THEN ‘In-lined table-function’
WHEN ‘K’ THEN ‘PRIMARY KEY or UNIQUE constraint’
WHEN ‘L’ THEN ‘Log’
WHEN ‘P’ THEN ‘Stored procedure’
WHEN . . . → Read More: Find all ‘SELECT *’ in your database
By Feodor, on April 21st, 2010%
Here is how to generate a script which drops all indexes in your database for SQL 2005 – 2008:
?View Code TSQLDECLARE @indexName VARCHAR(128)
DECLARE @tableName VARCHAR(128)
DECLARE [indexes] CURSOR FOR
SELECT I.[name] AS [Index],
S.[name] AS [Table]
FROM [sysindexes] I
INNER JOIN [sysobjects] S
ON I.[id] = S.[id]
WHERE I.[name] IS NOT NULL
AND S.[type] = ‘U’
AND I.INDID > 0
AND I.INDID < 255
AND (I.STATUS & 64)=0
–uncomment below to eliminate PK or UNIQUE indexes;
–what i . . . → Read More: Drop and create all indexes in a database
By sibir1us, on April 11th, 2010%
There are a few ways to do it:
either set the database in a single user mode
?View Code TSQLALTER DATABASE dbName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
or use the following code (this code I found on SQLServerCentral.com and is composed by Darwin Hatheway. The actual article was written by Brian Knight and can be accessed here.)
?View Code TSQLdeclare . . . → Read More: How to disconnect database users in SQL Server
By sibir1us, on March 27th, 2010%
As mentioned earlier (in this post), the recompilation of the execution plans is a costly operation. Here are some of the factors which affect the recompilation:
changes made to the schema or the table structure affected by the query
changes to or dropping of an index used in a query
updating statistics – whatever you do, DO NOT update . . . → Read More: What recompiles your execution plans?
