I have a column which contains unique ID's (e.g. 3ur56x960) as nvarchar characters. The data is fed in through an SSIS package in VS 2022.
I want to only allow values with a length of 9 characters to be entered when I run the SSIS package, without having it fail to execute.
What's the best way to set this limitation of column character length? Should I do this within the SSIS package, or directly in the table in SSMS?
So far I've seen I can change the data type to nvarchar(9) to limit to max 9 - but that wouldn't stop entries with less than 9 characters. I believe I can also add a CHECK constraint to the table or that I can somehow have a check from within the SSIS package (maybe like a lookup function to output match of a new column with length of ID?).
One option would be to use a conditional split in SSIS. Your Data Flow would look like this:
In the conditional split task, write an expression to check the length of the unique id column.
Then you map your Case 1 to the Destination task.
It will only write the 9-digit unique IDs to the destination. If you want to capture the non-9-digit ID's, you can create a Case 2 expression then map Case 2 to a different destination table.