Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8553309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:37:19+00:00 2026-06-11T14:37:19+00:00

all. I wrote an SSIS package that queries data from defined databases and puts

  • 0

all.

I wrote an SSIS package that queries data from defined databases and puts them into CSV files in a specific location. Then, within the SSIS package, I call a pre-written batch file that creates a folder in the specified directory, renames the folder to the date in format “yyyy-mm-dd”, and then move the created CSV files into the newly created folder.

Batch file code as follows:

@echo off
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%date:~6,6%-%date:~3,2%-%date:~0,2%
md \\remote_folder\%date%
move /Y \\remote_folder\*.csv \\remote_folder\%date%
exit

When running this from my SSIS package, everything works fine.

The service account that fires the agent jobs has full administrative control. When scheduling this as an automated job using the SQL Server Agent, the folder doesn’t get created properly. My thinking is that the SQL Agent either has trouble firing the batch file, or that they are incompatible.

Has anyone else come across this or know of a work-around?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:37:20+00:00Added an answer on June 11, 2026 at 2:37 pm

    Use File System Tasks:

    Create a variable called RmtArchPath (string)

    Set its value with the expression:

    “\\\\Remote_folder\\” + (DT_WSTR,4)YEAR(GETDATE()) + “-”
    + RIGHT(“0” + (DT_WSTR,2)MONTH(GETDATE()), 2) + “-”
    + RIGHT(“0” + (DT_WSTR,2)DAY( GETDATE()), 2)
    + “\\”

    Create a file system task. For operation choose Create Directory. For UseDirectoryIfExists choose True. For IsSourcePathVariable choose RmtArchPath.

    Create a second Variable called SrcFileName (string)

    Create a ForEachLoop Container. For Collection choose the enumerator “Foreach File Enumerator”, set the Folder = \\Remote_Folder, set the files = *.csv. For Variable Mappings set the variable = User::SrcFileName.

    Connect the File system task to the loop. (from the FS task to the loop for your flow direction).

    Create a second file system task inside the loop.

    Choose Move file for the operation. Set IsDestinationPathVariable to True, Set DestinationVariable = RmtArchPath. Set IsSourcePathVariable = True, Set SourceVariable = SrcFileName.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Purpose: Fetch all the user variables that are in the SSIS package and write
I wrote a function that selects all the users from my database and all
I'm currently creating an SSIS job that will pull picture data from a SQL
before this I wrote all jquery-code into main fail. Now I want to move
I wrote a tiny Bash script to find all the Mercurial changesets (starting from
I wrote an abstraction class for a math object, and defined all of the
First of all, I wrote a simple php page, that picks up some variables
Hi All I wrote a static library (libA) that uses another library (libB). How
SSIS package loops through input files. For each file, flatfile parse adds records to
I have done all that from This I have also made .ts and m3u8

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.