I have a table in SQL that looks like the below:
table is like the below:
Partno b5 b6 b7 A 3*38 4*38 5*38 B 4*1100 8*1100 15*1100
Column b5,b6,b7 is currently nvarchar. Can I check how to convert this column to int with the value of the multiplication? E.g if column b5=3*38 I would like to return as 114 etc.
Thank you very much.
With the following assumption, you can use split the query and do multiplication.
a*b
in the columnsYou can use following query:
Select partno,
PARSENAME(REPLACE(b5,'*','.'),2) * PARSENAME(REPLACE(b5,'*','.'),1) as b5_res,
PARSENAME(REPLACE(b6,'*','.'),2) * PARSENAME(REPLACE(b6,'*','.'),1) as b6_res,
PARSENAME(REPLACE(b7,'*','.'),2) * PARSENAME(REPLACE(b7,'*','.'),1) as b7_res
From your_table t