Home > SQLServer, SQLServer 2005, SQLServer 2008, SQLServer 2008 R2, Undocumented Functions > Undocumented Extended Stored Procedures – XPs

Undocumented Extended Stored Procedures – XPs

xp_fixeddrives is a useful extended stored procedure which returns amount of free space available in MB, for all local hard drives.

– © 2011 – Vishal (http://SqlAndMe.com)

EXEC master..xp_fixeddrives

drive MB free
—– ———–
C     91884
S     538

(2 row(s) affected)

It can be only used to check for free space on local drives, it won’t check mapped drives.

 

Another useful extended stored procedure is xp_fileexist, which can be used to check the existence of a file on file system.

– © 2011 – Vishal (http://SqlAndMe.com)

EXEC master..xp_fileexist 'C:\Windows\Explorer.exe'

File Exists File is a Directory Parent Directory Exists
———– ——————- ———————–
1           0                   1

(1 row(s) affected)

xp_fileexist can also be used to check existence of a directory:

– © 2011 – Vishal (http://SqlAndMe.com)

EXEC master..xp_fileexist 'C:\Windows\System32'

File Exists File is a Directory Parent Directory Exists
———– ——————- ———————–
0           1                   1

(1 row(s) affected)

It also checks if the Parent Directory exists.

 

Hope This Helps!

Vishal

If you like this post, do like my Facebook Page -> SqlAndMe
EMail me your questions -> Vishal@SqlAndMe.com
Follow me on Twitter -> @SqlAndMe

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 270 other followers

%d bloggers like this: