Question

I'm new to SSIS Package. I want to transfer data from source to destination database which has different table structures. My Data Flow is from OLE DB Source to OLE DB Destination enter image description here

I have named OLE DB Source as Patient Source and in OLE DB Source Editor, the connection is made with Source Database and in Data Access Mode I have selected SQL command and SQL command text as follows

select ppFName, ppLName, ppPersonalNbr, ppEmailOne from pat_Patients and as well as I have previewed the data, it shows 75 rows.

I want to transfer these four fields from this database to my source database table named Person and its table structure as above. enter image description here

The connection is made in OLE DB Destination Editor,

enter image description here and the mappings as follows,

enter image description here

When I run the project, my data flow is as follows,

enter image description here and I got three errors, in which first error states

[OLE DB Destination [2]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "The statement has been terminated.". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "Cannot insert the value NULL into column 'TenantId', table 'test_9.dbo.Person'; column does not allow nulls. INSERT fails.".

I know that TenantId and PersonId are both not null and 'foreign key' & 'primary key identity' respectively.

But I want to enter TenantId as '1' and PersonId as Identity i.e., auto-increment for all 75 rows from Patient Source. As well as I want to enter AddedBy as '1' and AddedDateTime to system current datetime.

I don't know how to achieve the above requirements, please anyone help me.

Thanks in advance.

Was it helpful?

Solution

You can use derived transformation to assign 1 when the TenantId is null

ISNULL([TenantId]) ? 1 : [TenantId] 

Similary for AddedBy column add an expression as 1 and for AddedDateTime column as GETDATE()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top