寫(xiě)個(gè)函數(shù) 自己調(diào)用處理就行了CREATE FUNCTION `NewProc`(format_vale VARCHAR(100)) RETURNS varchar(100)BEGIN DECLARE dec_number VARCHAR(4000); DECLARE dec_number_vale VARCHAR(4000); SET dec_number = ''; SET dec_number_vale = CAST(format_vale AS CHAR); WHILE dec_number_vale IS NOT NULL DO -- 剪切字符串 SET dec_number = right(dec_number_vale,1); IF dec_number = '0' || dec_number= '.' THEN SET dec_number_vale = LEFT(dec_number_vale ,LENGTH(dec_number_vale)-1); ELSE RETURN dec_number_vale; END IF; END WHILE;END;
創(chuàng)新互聯(lián)建站長(zhǎng)期為上千余家客戶(hù)提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為陳巴爾虎企業(yè)提供專(zhuān)業(yè)的做網(wǎng)站、網(wǎng)站制作,陳巴爾虎網(wǎng)站改版等技術(shù)服務(wù)。擁有10年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。
寫(xiě)個(gè)函數(shù) 自己調(diào)用處理就行了
CREATE FUNCTION `NewProc`(format_vale VARCHAR(100))
RETURNS varchar(100)
BEGIN
DECLARE dec_number VARCHAR(4000);
DECLARE dec_number_vale VARCHAR(4000);
SET dec_number = '';
SET dec_number_vale = CAST(format_vale AS CHAR);
WHILE dec_number_vale IS NOT NULL DO
-- 剪切字符串
SET dec_number = right(dec_number_vale,1);
IF dec_number = '0' || dec_number= '.' THEN
SET dec_number_vale = LEFT(dec_number_vale ,LENGTH(dec_number_vale)-1);
ELSE
RETURN dec_number_vale;
END IF;
END WHILE;
END;
DECLARE @i INT DECLARE @n INT DECLARE @t VARCHAR(20) SET @t='' SET @i=0 SELECT @n=len(sr1) FROM ts_2 --PRINT @n WHILE @i