Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Monday, April 11, 2011

Clearing All Rows From All Tables

This couple of SQL statements will delete all the rows from all tables.
  1. It disables referential integrity
  2. DELETES or TRUNCATES each table
  3. Enables referential integrity
  4. Reseeds rows with identity
-- disable referential integrity
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
GO

EXEC sp_MSForEachTable '
IF OBJECTPROPERTY(object_id(''?''), ''TableHasForeignRef'') = 1
DELETE FROM ?
else
TRUNCATE TABLE ?
'
GO

-- enable referential integrity again
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
GO

-- This will reseed each table [don't run this exec if you don't want all your seeds to be reset]
EXEC sp_MSForEachTable '
IF OBJECTPROPERTY(object_id(''?''), ''TableHasIdentity'') = 1
DBCC CHECKIDENT (''?'', RESEED, 0)
'
GO

Thanks to Mauro Cardarelli's post

BPC Processor Preferences

Based on this SQL Server Central post: a processor with more cores is better for Data Warehouses / Decision Support Systems (smells like OLAP). And at this time an Intel processor is better for a transactional system (OLTP).

Monday, November 22, 2010

SQL Server 2008 Releases

What is available:
  • SQL Server 2008 SP1 CU 11
  • SQL Server 2008 SP2 CU 1
  • SQL Server 2008 R2 SP CU2

Wednesday, October 6, 2010

32 bit ODBC DSN on a 64 bit machine

To create a 32 bit ODBC DSN run C:\Windows\SysWow64\odbcad32.exe

Wednesday, April 1, 2009

Moving Databases

For some reason pointing SharePoint to a different database server requires the renameserver command for stsadm. Here is a link: http://technet.microsoft.com/en-us/library/cc512725.aspx