10 Şubat 2010 Çarşamba

SQL Insert Yapılan Son Kayıt ID'si

SELECT @@IDENTITY
SELECT SCOPE_IDENTITY()
SELECT IDENT_CURRENT(‘tablename’)

SQL Backup & Restore

USE [DBName]
BACKUP DATABASE [DBName] TO DISK='[FileName]'

USE MASTER
RESTORE DATABASE [DBName] FROM DISK='[FileName]'

SQL Server Suspect Database Repair

USE Master
EXEC sp_resetstatus [DBNAME];
ALTER DATABASE [DBNAME] SET EMERGENCY
DBCC checkdb([DBNAME])
ALTER DATABASE [DBNAME] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ([DBNAME], REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE [DBNAME] SET MULTI_USER