当前位置: 代码迷 >> PB >> 用了一个SQL报错。苦闷了
  详细解决方案

用了一个SQL报错。苦闷了

热度:31   发布时间:2016-04-29 07:04:11.0
用了一个SQL报错。。。郁闷了
sql="
SELECT convert(char(20),isnull(a.item_no,''))+convert(char(20),isnull(a.item_subname,''))
+convert(char(20),isnull(a.item_size,''))
+case when convert(int,round(a.price,2)*100)%100=0 then convert(char(9),convert(dec(9,0),a.price)) when convert(int,round(a.price,2)*100)%10=0 then convert(char(9),convert(dec(8,1),a.price)) else convert(char(9),convert(dec(7,2),a.price)) end
+case when convert(int,round(a.sale_price,2)*100)%100=0 then convert(char(9),convert(dec(9,0),a.sale_price)) when convert(int,round(a.sale_price,2)*100)%10=0 then convert(char(9),convert(dec(8,1),a.sale_price)) else convert(char(9),convert(dec(7,2),a.sale_price)) end
+convert(char(8),item_clsno)
+convert(char(9),0)
FROM t_bd_item_info a
"


------解决方案--------------------
换行要要续行符 "&"

sql=" &
SELECT convert(char(20),isnull(a.item_no,''))+convert(char(20),isnull(a.item_subname,'')) &
+convert(char(20),isnull(a.item_size,'')) & &
+case when convert(int,round(a.price,2)*100)%100=0 then convert(char(9),convert(dec(9,0),a.price)) when convert(int,round(a.price,2)*100)%10=0 then convert(char(9),convert(dec(8,1),a.price)) else convert(char(9),convert(dec(7,2),a.price)) end
+case when convert(int,round(a.sale_price,2)*100)%100=0 then convert(char(9),convert(dec(9,0),a.sale_price)) when convert(int,round(a.sale_price,2)*100)%10=0 then convert(char(9),convert(dec(8,1),a.sale_price)) else convert(char(9),convert(dec(7,2),a.sale_price)) end &
+convert(char(8),item_clsno) &
+convert(char(9),0) &
FROM t_bd_item_info a &
"
  相关解决方案