Hi @Bone_12 ,
We recommend that you post CREATE TABLE statements for your tables together with INSERT statements with sample data, enough to illustrate all angles of the problem. We also need to see the expected result of the sample.
I can only assume this has something to do with the SubStrings but can't work out how to resolve
You could have a try with below replacement.
Replace below:
substring(a.rep_co,5,6) as job
With below:
CASE WHEN Isnumeric(substring(a.rep_co,5,6)) = 1 THEN substring(a.rep_co,5,6) ELSE null END as job
where would I place the INTO within this query please?
If the [mort_db].[dbo].[final_mort] table already exists, you could refer below as mentioned by other expert:
Insert into [mort_db].[dbo].[final_mort]
select * from ...
union
select * from ...
Otherwise refer below:
select *
into [mort_db].[dbo].[final_mort]
from
(select * from ...
union
select * from ...) a
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.