收缩当前SQLServer实例中所有的数据库
来源:懂视网
责编:小采
时间:2020-11-09 16:08:30
收缩当前SQLServer实例中所有的数据库
收缩当前SQLServer实例中所有的数据库:收缩当前SQLServer实例中所有的数据库 无 DECLARE @sql nvarchar(300)DECLARE ShrinkAllDBs CURSORREAD_ONLYFOR select name from sysdatabasesDECLARE @name nvarchar(255)OPEN ShrinkAllDBsFETCH
导读收缩当前SQLServer实例中所有的数据库:收缩当前SQLServer实例中所有的数据库 无 DECLARE @sql nvarchar(300)DECLARE ShrinkAllDBs CURSORREAD_ONLYFOR select name from sysdatabasesDECLARE @name nvarchar(255)OPEN ShrinkAllDBsFETCH

收缩当前SQLServer实例中所有的数据库 无 DECLARE @sql nvarchar(300)?DECLARE ShrinkAllDBs CURSORREAD_ONLYFOR select name from sysdatabases?DECLARE @name nvarchar(255)OPEN ShrinkAllDBs?FETCH NEXT FROM ShrinkAllDBs INTO @nameWHILE (@@fetch_statu
收缩当前SQL Server实例中所有的数据库
<无>
$velocityCount-->
DECLARE @sql nvarchar(300)
?
DECLARE ShrinkAllDBs CURSOR
READ_ONLY
FOR select name from sysdatabases
?
DECLARE @name nvarchar(255)
OPEN ShrinkAllDBs
?
FETCH NEXT FROM ShrinkAllDBs INTO @name
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
SET @sql = N'DBCC SHRINKDATABASE(N''' + @name + N''')'
EXEC sp_executesql @sql
END
FETCH NEXT FROM ShrinkAllDBs INTO @name
END
?
CLOSE ShrinkAllDBs
DEALLOCATE ShrinkAllDBs
GO
收缩当前SQLServer实例中所有的数据库
收缩当前SQLServer实例中所有的数据库:收缩当前SQLServer实例中所有的数据库 无 DECLARE @sql nvarchar(300)DECLARE ShrinkAllDBs CURSORREAD_ONLYFOR select name from sysdatabasesDECLARE @name nvarchar(255)OPEN ShrinkAllDBsFETCH