adminbd

Записи по mssql,oracle,windows и linux

Have a Question?

If you have any question you can ask below or enter what you are looking for!

Хранимая процедура. Информация о размере выбранной БД 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] 'имя базы'

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>