Showing posts with label ssis realtime scenarios. Show all posts
Showing posts with label ssis realtime scenarios. Show all posts

Thursday, July 3, 2025

File System Task in SSIS with Real-Time Scenarios

 

File System Task in SSIS with Real-Time Scenarios

The File System Task in SSIS is used to perform file and folder operations such as copying, moving, deleting, renaming, and setting file attributes. It is commonly used in ETL (Extract, Transform, Load) processes to manage files before or after data processing.


Key Features of the File System Task

  1. Operations Supported:

    • Copy – Copy a file/folder to a new location.

    • Move – Move a file/folder to a new location.

    • Delete – Remove a file/folder.

    • Rename – Change the name of a file/folder.

    • Create Directory – Make a new folder.

    • Set Attributes – Modify file attributes (Read-only, Hidden, etc.).

  2. Works with:

    • Local files

    • Network shared files (UNC paths)

    • FTP/SFTP (when combined with other tasks)

  3. No data transformation – Only file/folder manipulation.


Real-Time Scenarios for File System Task

1. Moving Processed Files to an Archive Folder

Scenario: After extracting data from a CSV file, move it to an archive directory to avoid reprocessing.
Solution: Use the File System Task with Move operation.

Configuration:

  • OperationMove file

  • Source ConnectionC:\ETL\Source\sales_data.csv

  • Destination ConnectionC:\ETL\Archive\sales_data_20240501.csv

  • Usage: After the Data Flow Task that processes the file.


2. Deleting Old Log Files

Scenario: Log files older than 30 days should be removed to save disk space.
Solution: Use a Script Task to identify old files + File System Task to delete them.

Configuration:

  • OperationDelete file

  • Source ConnectionC:\Logs\*.log (with a ForEach Loop to iterate files)

  • Condition: Delete if LastModifiedDate < (Today - 30 days)


3. Copying a File Before Processing (Backup)

Scenario: Before processing a file, create a backup copy in case of failures.
Solution: Use File System Task to Copy the file.

Configuration:

  • OperationCopy file

  • Source\\Shared\Incoming\orders.xlsx

  • Destination\\Shared\Backup\orders_backup.xlsx

  • Usage: Before the Data Flow Task that reads the file.


Monday, December 5, 2016

when i restore the sql database i am getting error

when i restore the sql database i am getting error

TITLE: Microsoft SQL Server Management Studio ------------------------------ Restore failed for Server 'MAIN'. (Microsoft.SqlServer.SmoExtended) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.2100.60+((SQL11_RTM).120210-1917+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Restore+Server&LinkId=20476 ------------------------------ ADDITIONAL INFORMATION: An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) ------------------------------ The backup set holds a backup of a database other than the existing 'abc' database. RESTORE DATABASE is terminating abnormally. (Microsoft SQL Server, Error: 3154) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.2100&EvtSrc=MSSQLServer&EvtID=3154&LinkId=20476 ------------------------------ BUTTONS: OK ------------------------------ 

Answer:
You're trying to overwrite existing database abc with a backup of a different database or a backup from another server.  The default action is not to allow that to happen.

If you're sure you're doing the right thing, add the WITH REPLACE option to the RESTORE DATABASE command and it will proceed.  You may also need WITH MOVE options if the backup came from a database whose files were in different locations that the abc database.