我的表中有一个名为salary的列。另一个表的值存储如
我想要结果
我创建了一个查询
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
在这里,我可以将单独的值相乘。我不能添加两个值。
当我使用上述查询时,我的结果是
INSERT INTO jobs(Budget) VALUES(200000,5000)
预期输出:
INSERT INTO jobs(Budget) VALUES(205000)
答案 0 :(得分:5)
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