On a 64-bit computer, you install an instance of the 32-bit (x86-based) version of Microsoft SQL Server 2008. On the same computer, you install an […]
Continue readingCategory: SQL
SQL
Enable Service Broker on SQL
To determine whether or not Service Broker is enabled, execute the following T-SQL: SELECT is_broker_enabled FROM sys.databases WHERE name = ‘DatabaseName’; — Where ‘DatabaseName’ is […]
Continue readingWITH Syntax to Delete Duplicate Records with No Primary Key
If you are missing a primary key, here is a great way to delete duplicate records in an SQL table. This example uses WITH to […]
Continue readingCleaning up my log file in SQL 2008 R2
This morning I noticed that my log file was 450 GB. With only 30 GB remaining on the drive, I had to shrink the file. […]
Continue readingQuery Size of Tables in T-SQL
Useful command for SQL 2005 and above to see the size of each table in a given database: USE databasename EXEC sp_MSforeachtable @command1=”EXEC sp_spaceused ‘?'” […]
Continue readingQuery the INFORMATION_SCHEMA for Table Information
A very useful command to query for information about a table from INFORMATION_SCHEMA. Select * From INFORMATION_SCHEMA.COLUMNS Where TABLE_NAME=’TableName’
Continue readingShow File Stats
This DBCC SHOWFILESTATS command provides you with the data files for the current database that you select. DBCC SHOWFILESTATS or DBCC SHOWFILESTATS WITH NO_INFOMSGS will […]
Continue readingWITH Syntax to Create a Temporary Table
The WITH (common_table_expression) command creates a temporary table that can be used in a SELECT, INSERT, UPDATE, MERGE, or DELETE statement. Very useful for creating […]
Continue readingReturn Top 1 Field in a JOIN statement
This is a nice solution in that it groups the field used in the join statement. You can use this technique in many situations. I […]
Continue readingMultiple Commands Within a CmdExec Job Step
One irritating problem with the Operating System (CmdExec) SQL Job Type is that you can only run a single command. Most people get around this […]
Continue reading