Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Create File in Windows FileSystem

Author  Topic 

gpc44
Starting Member

35 Posts

Posted - 2013-03-07 : 10:36:42
Hello,
Is there a way to create a T-SQL an empty text file in the file system - no xp and sp_configure?

Regards
Nicole

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-07 : 10:45:37
You mean without using xp_cmdshell? You could use a CLR stored procedure. (You would need to mark the stored proc for EXTERNAL_ACCESS for it to have sufficient privilege to create files in the OS file system)
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2013-03-07 : 11:28:28
You could use sp_OACreate and create and instance of the FileSystemObject...assuming that OLE Automation is enabled and you (and the service account) have enough permissions.

Not the best idea usually though. What is it that you need to accomplish? May be a better way...


EDIT: 2nd link didn't format right...should be: http://msdn.microsoft.com/en-us/library/aa242706(v=vs.60).aspx
Go to Top of Page
   

- Advertisement -