Showing posts with label best ssis interview questions. Show all posts
Showing posts with label best ssis interview questions. Show all posts

Monday, June 23, 2025

TOP 7 REAL TIME SSIS Scenarios with solutions

 ### **Real-Time Scenarios in SSIS with Solutions**  


SSIS (SQL Server Integration Services) is widely used for **ETL (Extract, Transform, Load)** processes. Below are some **real-world SSIS challenges** and their solutions.  


---


## **1. Scenario: Slow Data Load from Source to Destination**  

### **Problem:**  

- A large dataset (millions of rows) is taking too long to load.  

- The package fails due to timeouts.  


### **Solutions:**  

✔ **Use Batch Processing** – Split data into smaller chunks (e.g., 10,000 rows per batch).  

✔ **Optimize Destination Settings** –  

   - Use **Table Lock** for bulk inserts.  

   - Set **Batch Size = 10,000** in the OLE DB Destination.  

✔ **Increase Buffer Size** – Adjust **DefaultBufferMaxRows** and **DefaultBufferSize** in Data Flow properties.  

✔ **Use Fast Load Option** – Enable **"Fast Load"** in OLE DB Destination.  


---


## **2. Scenario: Handling Flat File Import Errors**  

### **Problem:**  

- A CSV file has missing columns, wrong data types, or corrupt rows.  

- The package fails and stops processing.  


### **Solutions:**  

✔ **Use Error Outputs** – Redirect bad rows to an error log table.  

✔ **Data Conversion Task** – Explicitly convert columns before loading.  

✔ **Flat File Source Error Handling** –  

   - Set **"Ignore truncation errors"** if needed.  

   - Use a **Script Component** to validate data before loading.  


---


## **3. Scenario: Dynamic File Import (Changing File Names)**  

### **Problem:**  

- Need to import files with names like `Sales_20240623.csv`, `Sales_20240624.csv`, etc.  

- Hardcoding filenames is not scalable.  


### **Solutions:**  

✔ **Use Variables & Expressions** –  

   - Set a variable like `User::FileName = "Sales_" + (DT_STR, 8, 1252)GETDATE() + ".csv"`  

   - Use **Expressions** in the **Flat File Connection Manager** to dynamically set the file path.  

✔ **Foreach Loop Container** – Loop through all files in a folder.  


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.

Copy All Tables from IBM DB2 schema to SQL Server

I am trying to come up with the best and most efficient way to copy more than 700+ tables from an IBM DB2 iSeries schema to SQL Server. I have tried the followings:

1. I have exported all the 700+ tables into csv files but I am not able to upload them all in one batch to SQL. I can upload one table at time but it too time consuming

2. Created SSIS package to directly copy table form IBM to SQL but that's gain working for only one table at a time

Any recommendations as what tool(s) or methods to use for copying/uploading multiple tables from IBM to SQL?

ANS:
If you create a table that lists all the tables/files to be imported, and a script that takes a filename and imports the file (possibly with BULK INSERT), you could run multiple copies of that script to do parallel imports.  A flag bit in the table could be used to mark which tables have been chosen by one of the script copies.