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)
 set folder permission

Author  Topic 

mejo11
Starting Member

2 Posts

Posted - 2013-03-05 : 11:09:27
I have a stored procedure that creates a file/folder, I need to set permission on that folder.
I have searched and searched and can't figure out how to do that, is there a way using tsql.

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-05 : 11:25:09
There is no native T-SQL command that can change permissions on a folder on the OS. You can use xp_cmdshell to run system commands which in turn would do that. This page has info and examples on xp_cmdshell: http://msdn.microsoft.com/en-us/library/ms175046.aspx

By default xp_cmdshell is disabled. If you need to enable it see here: http://msdn.microsoft.com/en-us/library/ms190693.aspx
Go to Top of Page

mejo11
Starting Member

2 Posts

Posted - 2013-03-05 : 11:58:59
Thanks, I was afraid there was not direct way to do it. I know how to copy, move, create using xp_cmdshell but I dont' know how to set security on the folder. Suggestions?
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-05 : 12:11:52
I have not done that from a command line. This MSDN page might help: http://support.microsoft.com/kb/288292
Go to Top of Page
   

- Advertisement -