0

Clean your SQL Server database!

Posted by Tim on December 23, 2009 in SQL Server

Here are some lines of code that can help clean your database from test data so you can start over with a fresh canvas. /* Disable constraints and triggers (if any) */ exec sp_MSforeachtable ‘ALTER TABLE ? NOCHECK CONSTRAINT ALL’ exec sp_MSforeachtable ‘ALTER TABLE ? DISABLE TRIGGER ALL’ /*Perform delete operation on all table for [...]

Tags: ,

 
0

Selecting a row position within a SELECT query

Posted by Tim on March 11, 2009 in SQL Server

I want to get the third row in a result set from the following: ID   Name 1   A 2  B 3  C 4 D You can acheive this by using the ROW_NUMBER() rank function using SQL Server 2005/2008.   The following code will return the 3rd record. create table #temp ( ID int, [Name] nvarchar(50) ) [...]

Tags: ,

 
0

SQL Server Express 2008 Maintenance Script

Posted by Tim on November 14, 2008 in SQL Server

The issue I have with SQL Server Express Edition 2008 is that the SQL Agent is disabled and according to Microsoft, this has been disabled on purpose.   So, how do we schedule jobs to do such tasks as Rebuilding Indexes, Full-text Catalogs etc?   I use the Task Scheduler on Windows 2008 Server that executes a [...]

Tags: ,

Copyright © 2008-2010 Tim's CodeLab Blog All rights reserved.
Desk Mess Mirrored v1.7 theme from BuyNowShop.com.