When I call: select * from tblTarget Order By 1
Note: Table tblSource in this link is different than from the one used to produce the attached image. See T-SQL below for the new table definition.
I get the result in the attached image
create TABLE tblSource(
create TABLE tbltarget(
--select * from tblSource
insert into tblSource (f1, f2, f3, f4, f5)
values('C','R','Q','Z', 'W'),(NULL,'X',NULL,'GZ', 'HW'),('D',NULL,NULL,'CZ', 'MW'),(NULL,'P','P','IZ', 'UW'),(NULL,'UX',NULL,'GZ', NULL)
So, as you can see the results shown in the attached image doesn't sort well. I was thinking if we could add a new sort column called f0 (int type no index) to tblTarget in the abcd stored procedure shown on the first link in this question, then we can have:
f0 f1 f2 f3 ....
Then we can sort in by:
select * from tblTarget Order By f0
Question: How could this be coded?