Results 1 to 6 of 6

Thread: Renaming files with TSQL

  1. #1
    Join Date
    Oct 2002
    Posts
    34

    Renaming files with TSQL

    I want to be able to rename a file in a specific folder using TSQL or a stored procedure.

    More generically, I want to be able to perform file operations (i.e. renaming, copying, deleting etc.) at the OS level using TSQL.

    Is there a stored procedure or other command in TSQL that facilitates this?

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Use xp_cmdshell. This allows you to run any command that you can run from a DOS command prompt.

    But you need to have permission to run xp_cmdshell usually reserved for sysadmin role only.

  3. #3
    Join Date
    Oct 2002
    Posts
    34
    Unfortunately, I will need all users to be able to run the process that will perform the file operations.

    I think I can work around this though if I can figure out how to call a very simple DTS package from a stored procedure. The package had no security requirements or parameters; it simply needs to execute.

    Have you any advice for calling such a DTS package from a stored proc?

  4. #4
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    why can't the users run the DTS package using a vbscript or DTSrun utility or from a web page?

  5. #5
    Join Date
    Oct 2002
    Posts
    34
    Neither VB or a Web page is part of the picture. I need to learn more about the DTSRun utility.

    That's where I'll look.

    Thank you.

  6. #6
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Though it is a security hole, you can grant execute privilege on xp_cmdshell to users.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •