Friday, June 5, 2009

Enabling SQL Server to access directories...

I am working on SQL Server nowadays and while writing a component to restore a database programatically from a backup file one needs to access the file system from within the database.

Now normally a database won't allow you to do so as ideally a database shouldn't depend on anything outside it. Even the metadata of database's own schema is stored within the database (One of the basic principles of database).
In order to enable database to access the file system we can use the following script...

exec sp_configure 'show advanced options', 1
go
reconfigure
go
exec sp_configure 'xp_cmdshell', 1
go
reconfigure
go
exec sp_configure 'show advanced options',0
go
reconfigure


Happy coding,

Abhishek

No comments: