本文介绍了如何在存储过程中将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转换为整数
发布评论