Using string_split to store data in multiple columns instead of just one?
To guarantee column ordering you can't rely on string_split so need a different user defined function. This one returns the same value column and also a seq column for row ordering:
create function dbo.SplitString(@string varchar(max), @Delimiter varchar(1))
returns table
as
return(
select j.[value], 1 + Convert(tinyint,j.[key]) Seq
from OpenJson(Concat('["',replace(@string, @delimiter , '","'),'"]')) j
);
You can then make use of it as follows to create the columns from the sample string and insert into the target table:
declare @string2 varchar(max)='DOB;Mar 1199;passport;AW1234567', @sep char(1)=';'
insert into Employee(Dob1, DobNum, Pass1, PassNum)
select
Max(case when Seq=1 then Value end) Dob1,
Max(case when Seq=2 then Value end) DobNum,
Max(case when Seq=3 then Value end) Pass1,
Max(case when Seq=4 then Value end) PassNum
from dbo.SplitString(@string2, @sep);
Example Fiddle