Die Procedure kann natürlich nur von einer anderen Datenbank
ausgeführt werden... da sie gesperrt werden muß.
Schätze das interessiert noch andere.....
> Gibt es eigentlich sowas wie Compact Database in SQL-Express....
sp_attach_db und sp_detach_db sind von mir eingefügt....
Gruß, Chris
Create PROCEDURE dbo.CompactDatabase
@DBName varchar(20),
@DBPath varchar(50)
as
/* Nur wenn die DB nicht sowieso im SQLServer registriert ist*/
EXEC sp_attach_db @DBName,@DBPath
/*Set the database in single user mode.*/
EXEC sp_dboption @DBName , 'single user', 'TRUE'
/*This command will shrink the database size to the
size + percentage of free space. The truncateonly
attribute releases the shrunken space to the operating system.*/
DBCC ShrinkDatabase ( @DBName, 10,TRUNCATEONLY)
/*checks the integrity of the db, and repairs some issues
without data loss. This will rebuild your indexes.*/
DBCC CheckDB(@DBName, REPAIR_REBUILD )
EXEC sp_dboption @DBName, 'single user', 'False'
/* Nur wenn die DB nicht sowieso im SQLServer registriert ist*/
EXEC sp_detach_db @DBName
_______________________________________________
Asp.net Mailingliste, Postings senden an:
[email protected]
An-/Abmeldung und Suchfunktion unter:
http://www.glengamoi.com/mailman/listinfo/asp.net
_______________________________________________
Asp.net Mailingliste, Postings senden an:
[email protected]
An-/Abmeldung und Suchfunktion unter:
http://www.glengamoi.com/mailman/listinfo/asp.net