Wednesday, March 21, 2012

GetDate()

I would like to exec master..xp_fixeddrives which will give you the list of
physical drives sqlserver sees. Output is Drives, FreeSpace from
xp_fixeddrives.
I would like to write this information to a table with Drive,
FreeSpace,SampleTime.
The SampleTime will be the getdate() function.
Please help me with this issue.
ThanksCREATE TABLE #DriveData
(
Drive CHAR(2),
FreeSpace BIGINT,
SampleTime DATETIME NOT NULL DEFAULT GETDATE()
);
INSERT #DriveData
(
Drive,
FreeSpace
)
EXEC master..xp_fixeddrives;
SELECT Drive, FreeSpace, SampleTime
FROM #DriveData;
DROP TABLE #DriveData;
"Joe K." <Joe K.@.discussions.microsoft.com> wrote in message
news:23A81366-D8DD-4833-B25C-96DF0561090D@.microsoft.com...
>I would like to exec master..xp_fixeddrives which will give you the list of
> physical drives sqlserver sees. Output is Drives, FreeSpace from
> xp_fixeddrives.
> I would like to write this information to a table with Drive,
> FreeSpace,SampleTime.
> The SampleTime will be the getdate() function.
> Please help me with this issue.
> Thanks
>
>|||CREATE TABLE #diskspace(
drivename VARCHAR(50),
MBFree INT)
INSERT INTO #diskspace(drivename,MBFree) exec master..xp_fixeddrives
SELECT * FROM #diskspace|||CREATE TABLE #diskspace(
drivename VARCHAR(50),
MBFree INT)
INSERT INTO #diskspace(drivename,MBFree) exec master..xp_fixeddrives
SELECT * FROM #diskspace|||Note the addition of the date field to the table.
CREATE TABLE #diskspace(
drivename VARCHAR(50),
MBFree INT,
sampledate DATETIME default getdate()
)sql

No comments:

Post a Comment