Showing posts with label SSIS. Show all posts
Showing posts with label SSIS. Show all posts

Wednesday, September 18, 2019

SSIS - Start job with different account (credencials)

SSIS - Start job with different account (credentials)

1. Create new credentials (existing AD/local user)  at SQLServer->Security-Credentials


2. Create proxy SQLAgent->Proxies->SSIS Package execution (if you want to use it for ssis package)


3. At job step choose run as (created proxy)


SSIS - odbc oracle delete query

SSIS - problem with odbc oracle delete query


SQL delete query which is not affecting any records will return the result SQL_NO_DATA. SSIS odbc is not able to handle this kind of result.

1. Create query with dual select at the end
delete from table;
select 1 from dual;

2. Create procedure to delete data

create or replace PROCEDURE  delete_table is
begin
delete from table;
end;


Source: https://stackoverflow.com/questions/55000421/delete-statement-fails-when-called-from-ssis

SSIS - Call oracle procedure from Microsoft SQL Server integration services

SSIS - Call oracle procedure from Microsoft SQL Server integration services





1. Create sample procedure f.e.

create or replace PROCEDURE  schema1.delete_proc is
begin
delete from table;
end;

2. Add Execute SQL Task component at your ssis project with following parameters


3. Syntax
{CALL <schema>.<procedure>}
{CALL <schema>.<procedure>(parameter1='value1')}





Tuesday, November 27, 2018

SSIS SQL Server Integration Services - Using variable in SSIS Send Email Task, Send email to dynamic address

1. Create variables for FromLine, ToLine, Subject and Source

f.e EmailFrom, Email, EmailSource, EmailSubject


2. Fill variables (you can do it dynamically at script task)
3. Fill send email task as below

4. Fill expression tab as below




Monday, November 26, 2018

SSIS SQL Server Integration Services - execute query based on flat file csv datasource

SSIS SQL Server Integration Services - execute oracle query based on flat file csv datasource


1. Create variable to store file path

f.e. 

FilePath with value C:\file.txt
File.txt will be ";" separeted flat file. I will use second column of file with material numbers.

2. Create variable to store query you wish to execute

f.e Query which will later be referenced as User::Query

3. Create script task to read file contents and prepare query

4. Create Execute SQL Task to run query created inside previous script task, using variable User::Query



// Script

public void Main() { // TODO: Add your code here //get file path string FilePath = Dts.Variables["User::FilePath"].Value.ToString(); string temp; string email = "przemyslaw.wawrzyczek@valeo.com"; string content = ""; int i = 0; bool contentExists = false ; // Open file reader StreamReader sr = new StreamReader(FilePath); // Loop while end of file, read line while ((temp = sr.ReadLine()) != null) { // Split into columns string[] columns = temp.Split(';'); // Skip header if (i > 0) { //Get distinct values if (!content.Contains(columns[1])) { // add value content += "'" + columns[1] + "',"; email = columns[12].ToString(); contentExists = true; } } else { // open bracket content = "("; } i++; } //remove last coma content = content.TrimEnd(','); //close bracket content += ")"; if (contentExists) { // create query and pass it into ssis variable Dts.Variables["User::Query"].Value = "BEGIN DELETE FROM TABLE WHERE material_number in " + content + "; COMMIT; END;"; Dts.Variables["User::Email"].Value = email; content = content.Replace("'", ""); Dts.Variables["User::EmailSubject"].Value += " " + content; Dts.TaskResult = (int)ScriptResults.Success; } else { Dts.Variables["User::Query"].Value = ""; Dts.TaskResult = (int)ScriptResults.Failure; } }

Tuesday, November 20, 2018

SSIS SQL Server Integration Services - limit number of rows

SSIS SQL Server Integration Services - limit number of rows

SSIS Microsoft Sql server

1. Use Row Sampling component from toolbox

2. Double click at Row Sampling component to set number of rows

 3. Set Sampling selected output to redirect selected number of rows

4. Set Sampling unselected output to redirect all rows available




Problem with database open ORA-19804, ORA-19809, ORA-03113

1. Try to login to database with SYS AS SYSDBA user. If the instance is idle, run the startup command. 2. If ORA-03113 occured, check the la...