Question

i want to display 2 values in dropdown list and those two fields are nvarchar.

i have try with following query it is working fine for int but no works for nvarchar because alignment issue

select REPLACE(STR(InventoryID, 3), SPACE(1), '0') + ' | ' + Description from InventoryMaster.

i need this result

enter image description here

but get

enter image description here

Thanks in advance.

No correct solution

OTHER TIPS

SELECT Right(Replicate('0', 11) + Cast(InventoryID As varchar(11)), 11)
     + ' | '
     + Description As field_name
FROM   your_table

This will pad your InventoryID with leading zeroes, 11 to be exact, as this is the maximum number of "characters" an field of datatype int can be (-2,147,483,648).

Then it appends | (space, pipe, space) before finally adding the description field

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top