Skip to content

Instantly share code, notes, and snippets.

@keyvan
Created August 28, 2011 01:45
Show Gist options
  • Save keyvan/1176131 to your computer and use it in GitHub Desktop.
Save keyvan/1176131 to your computer and use it in GitHub Desktop.
The SQL script to remove fake test items in NerdDinner database based on the keyword "test" and the date difference in future.
DECLARE @CurrentDate datetime
SET @CurrentDate = getutcdate()
DECLARE @Days int
SET @Days = 180
DELETE [NerdDinner].[dbo].[RSVP]
WHERE [DinnerID] in
(SELECT [DinnerID]
FROM [NerdDinner].[dbo].[Dinners]
WHERE
[Title] LIKE '%test%'
OR [Description] LIKE '%test%'
OR (DATEDIFF(DAY, @CurrentDate, [EventDate]) >= @Days)
)
DELETE [NerdDinner].[dbo].[Dinners]
WHERE
[Title] LIKE '%test%'
OR [Description] LIKE '%test%'
OR (DATEDIFF(DAY, @CurrentDate, [EventDate]) >= @Days)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment