Хранимая процедура. Информация о размере выбранной БД MS SQL Server
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[getSpaceUsedSingleDB] -- имя БД @name nvarchar(24) AS BEGIN SET NOCOUNT ON -- Create a tempory table DECLARE @SpaceUsed TABLE ( name nvarchar(24), db_size nvarchar(13), owner nvarchar(24), dbid smallint, created char(11), status varchar(340), compatibility_level tinyint ) --Populate the table INSERT INTO @SpaceUsed EXEC sp_helpdb --Select the size of the specified table SELECT CONVERT (DECIMAL, REPLACE (db_size, 'MB', '')) AS [size] FROM @SpaceUsed WHERE name = @name END
Выполнить процедуру
exec [dbo].[getSpaceUsedSingleDB] 'имя базы'