Sql Server

Delete records in a batch


WHILE 1 = 1
BEGIN
DELETE TOP(50000) [mySchema].[DimStatic] WITH (XLOCK)
WHERE [PKDimStaticID] NOT IN (SELECT [FKDimStaticID] FROM [#tt])
IF @@rowcount < 1 BREAK; END

Tags: , ,

Friday, March 2nd, 2012 SQL Server No Comments

SQL SERVER DATABASE LAST RESTORED DATE


use msdb;
select
h.destination_database_name RestoredTo,
h.restore_date RestoreDate,
b.database_name RestoredFrom,
f.physical_name SourceFile,
b.backup_start_date BackupDate
from dbo.RestoreHistory h
inner join dbo.BackupSet b
on h.backup_set_id = b.backup_set_id
inner join dbo.BackupFile f
on f.backup_set_id = b.backup_set_id
order by RestoreDate desc

Tags: , , ,

Monday, October 4th, 2010 Uncategorized No Comments

Which version, level, edition of Sql Server am I using?

SELECT
	SERVERPROPERTY('productversion'),
	SERVERPROPERTY ('productlevel'),
	SERVERPROPERTY ('edition')

Tags: , ,

Friday, April 25th, 2008 SQL Server No Comments