Monday, 7 April 2025

Schedule SSIS Package

 Scheduling SSIS pacakage in windows Task scheduler



To schedule an SSIS package to run every hour using Windows Task Scheduler, follow these steps:


1. **Create the SSIS Package**:

   - Develop your SSIS package using SQL Server Data Tools (SSDT) and save it to a location accessible by the server.


2. **Create a Batch File**:

   - Create a batch file (`.bat`) that will execute the SSIS package using the `dtexec` utility. The `dtexec` utility is used to configure and execute SSIS packages.

   - Example content of the batch file:


     @echo off

     dtexec /f "C:\Path\To\Your\Package.dtsx"


   - Save this batch file to a location accessible by the server.


3. **Open Task Scheduler**:

   - Open Task Scheduler by typing "Task Scheduler" in the Windows search bar and selecting the application.


4. **Create a New Task**:

   - In the Task Scheduler, click on "Create Task" to create a new task.

   - Provide a name and description for the task.


5. **Set the Trigger**:

   - Go to the "Triggers" tab and click "New".

   - Set the trigger to begin the task "On a schedule".

   - Choose "Daily" and set the "Recur every" field to 1 day.

   - Check the box for "Repeat task every" and set it to 1 hour.

   - Set the "for a duration of" field to "Indefinitely" if you want it to run continuously.

   - Click "OK" to save the trigger.


6. **Set the Action**:

   - Go to the "Actions" tab and click "New".

   - Choose "Start a program" as the action.

   - Browse to the batch file you created earlier and select it.

   - Click "OK" to save the action.


7. **Configure Additional Settings**:

   - Go to the "Conditions" tab and configure any additional settings as needed.

   - Go to the "Settings" tab and ensure the task is set to run whether the user is logged on or not, if necessary.

   - Check the box for "Allow task to be run on demand" if you want to manually run the task.


8. **Save and Test the Task**:

   - Click "OK" to save the task.

   - Test the task by manually running it from the Task Scheduler to verify it works.


By following these steps, you can schedule your SSIS package to run every hour using Windows Task Scheduler.


Saturday, 5 April 2025

Python

Connecting to SQL databse and inseting the data using Python



# Azure SQL Database connection details
server = 'ServrerName'
database = 'DatabaseName'  # Replace with your database name
username = 'UserId'
password = 'Password'
driver = 'ODBC Driver 17 for SQL Server'

# Create the connection string
connection_string = f'mssql+pyodbc://{username}:{password}@{server}/{database}?driver={driver}'

# Create the SQLAlchemy engine
engine = create_engine(connection_string)

# Insert the data into the Azure SQL Database

partspec_insert.to_sql('Part', con=engine,schema='LSQ', if_exists='append', index=False)








Python

 Ranaming a column in data frame




Writing the Read data into Excel sheet

  • Here if_sheet_exists = 'replace' will overite the data in the sheet if the sheet exists already
import pandas as pd
#Data frame
partspec_insert=df[['PartId', 'PartRev', 'AddedBy']]
#Write the DataFrame to a new sheet in the same Excel file
with pd.ExcelWriter(file, engine='openpyxl', mode='a', if_sheet_exists = 'replace') as writer:
      partspec_insert.to_excel(writer, sheet_name='Processed Data', index=False)







Moving file to destination folder after processing


import os
import shutil
destination_folder_path=r'C:\Users\BK2\Desktop\Test Folder\Processed Files'
shutil.move(file, os.path.join(destination_folder_path, os.path.basename(file)))
Print('Files moved to Destination Folder')





Drop Duplicates from Dataframe






Friday, 4 April 2025

Power Bi

 Select Distinct of Part Number For 2 Dim Tables and make it Fact table



Monday, 31 March 2025

Python Learnings

 Adding Column in Data Frame

  • In the Below we are going to add a new column and add a auto numbering
Code and Output