如何在存储过程中将varchar转换为整数

编程入门 行业动态 更新时间:2024-10-26 00:21:14
本文介绍了如何在存储过程中将varchar转换为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,如果您能帮助我解决问题,我将不胜感激.我需要编写获取字符串的存储过程.字符串中的每个char必须转换为int类型,并且转换后的类型必须插入到表中. 知道要这么做吗? 预先谢谢您.

Hello I would be grateful if you could help me to solve the problem. I need to write stored procedure that gets string. Each char in string have to be converted to int type and the converted type have to be inserted to the table. Any idea haow to do it? Thank you in advance.

推荐答案

对于MSSQL For MSSQL convert(int,'01235')

DECLARE @Pos int SET @Pos=1; DECLARE @inputString varchar(10) SET @inputString='012345' DECLARE @intValue int while(@Pos<=LEN(@inputString)) BEGIN SET @intValue = CONVERT(int,substring(@inputstring,@Pos,1)); INSERT INTO myTable(myfield) Values(@intValue); SET @Pos=@Pos+1 END

更多推荐

如何在存储过程中将varchar转换为整数

本文发布于:2023-10-29 03:25:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:整数   转换为   过程中将   如何在   varchar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!