如题
数据库为sql2005
------解决方案--------------------
H:\>dir h:\m*
Volume in drive H is xxxxxx
Volume Serial Number is 0000-0000
Directory of h:\
03/09/2009 12:55p <DIR> My Databases
04/29/2010 12:19p <DIR> My AppData
05/03/2010 08:08p <DIR> My Documents
11/06/2008 05:07p <DIR> My Data
0 File(s) 0 bytes
4 Dir(s) 220,545,024 bytes free
H:\>
------解决方案--------------------
执行下面的sql可以得到当前所在的数据库的数据文件所在的盘符的剩余空间(MB)
declare @drivename char(1)
select @drivename=left(filename,1) from sysfiles where fileid= 1
if not exists(select 1 from tempdb.dbo.sysobjects where name like '#FreeSpace%' and type='U')
create table #FreeSpace(
Drive char(1),
MB_Free int
)
else
truncate table #FreeSpace
insert into #FreeSpace
exec xp_fixeddrives
select MB_Free from #FreeSpace where Drive = @drivename
go