Clean your SQL Server database!
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 [...]
Selecting a row position within a SELECT query
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) ) [...]
SQL Server Express 2008 Maintenance Script
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 [...]


