Ideas / Advise Requested - how to replicate 'TRY_CAST' in EasyMorph

Hello everyone,
I'm a brand new EasyMorph user testing it's capabilities - but I have a requirement that is quite specific.

I have an existing Microsoft SQL Server solution which contains a table with a column which has been populated with undefined data and therefore has a nvarchar(MAX) column data type assigned.

The current process runs iteratively using the 'TRY_CAST' function against the column to assess what the most likely data content is from the results:

|Try_Cast Iteration Number | Try_Cast Iteration Type | Pass % | Fail %|

|--- | --- | --- | ---|
|1 | UniqueIdentifier | 0% | 100%|
|2 | DateTime | 0% | 100%|
|3 | Date | 0% | 100%|
|4 | Integer | 7% | 93%|
|5 | Money | 12% | 88%|
|6 | Float | 95% | 5%|

We're moving away from MS SQL Server solution to PostgreSQL where the TRY_CAST function is unavailable - so I can't just replicate that.

I wondered if anyone could suggest any similar functionality available in EasyMorph to allow me to 'test' the content of a column to work out the most appropriate data type for that column?

Any help / advise is very much appreciated.

try_cast_resulst

Kind regards,
Richard.

Hello Richard, and welcome to the Community!

EasyMorph has several built-in test functions that you can use to test data types. For instance:

You can use these functions inside the "Rule" action to test a value against several data types, as below:

test-data.morph (3.6 KB)

Of course, these functions may not cover all the cases, so you may need to use other functions to parse the unknown values.

Finally, the results of tests can be aggregated into a table similar to the one in your post using the "Aggregate" action.

1 Like

Hi Dmitry,

These look like some very good options to get me started - thank you.

I'll give these and the 'rule' option a go and see if they can do everything I need.

Thanks very much for your help - much appreciated.

Richard.