add two types of casting into single column
casting, sql, sql-server, sql-server-2008
Solution
SELECT TOP(10) 'INSERT INTO jobs(Budget) VALUES('+
CAST(SUBSTRING(CAST(r.Budget AS VARCHAR(50)), 0, PATINDEX('%laks%', r.Budget))*100000
+ SUBSTRING(CAST(r.Budget AS VARCHAR(50)), PATINDEX('%laks%', r.Budget) + 4,
patindex('%Thousands%', r.Budget) - PATINDEX('%laks%', r.Budget) - 4)* 1000 AS VARCHAR(50))+')'
FROM requirementsdetailsfororganization r
Problem
I have column called salary in my table. Another table the values are stored like - 5 lakhs 12 thousand likewise.. I want the result - 5*10000+12*1000 I created one query, ``` SELECT TOP(10) 'INSERT INTO jobs(Budget) VALUES('+ CAST(SUBSTRING( CAST(r.Budget AS VARCHAR(50)), 0, PATINDEX('%laks%', r.Budget))*100000 AS VARCHAR(50)) + ',' +CAST(SUBSTRING( CAST(r.Budget AS VARCHAR(50)), PATINDEX('%laks%', r.Budget) + 4 ,patindex('%Thousands%', r.Budget) - PATINDEX('%laks%', r.Budget) - 4)* 1000 AS VARCHAR(50))+')' FROM requirementsdetailsfororganization r ``` Here I can multiply separate values. I can't do add two values. when i use above query my result is ``` INSERT INTO jobs(Budget) VALUES(200000,5000) ``` Expected output: ``` INSERT INTO jobs(Budget) VALUES(205000) ```