字符串截取的方式有哪些呢?
字符串截取的方式有哪些呢?
字符串的截取,在此提供两种方式:一种使用C#语言的split()函数;另一种使用存储过程来实现。 字符串的截取,在此提供两种方式: 一种使用C#语言的split()函数 另一种使用存储过程来实现 (一)使用split()函数 string str="1/2/3/444/3333/222/5555/"; string[] arr_str; arr_str=str。
split('/') for(int i=0;i { Response。Write(strData[i]+" "); } (二)使用存储过程 将字符串分割后存放在临时表中,然后将数据返回! ALTER procedure [dbo]。
[ZXKS_KS_getjzxx] @jzbh int as 创建临时表,用来保存试题编号 create table temp_table ( id int IDENTITY(1,1) primary key, stid int ) DECLARE @object_id nvarchar(500) DECLARE @i INT DECLARE @len INT Declare @string nvarchar(500) 根据卷子编号获取试题编号字符串 set @string =(select stid from ks_jzxx where jzid=@jzbh) 将试题编号字符串进行拆分,然后放在临时表中 IF (@string IS NULL) OR (LTRIM(@string) = '') RETURN WHILE CHARINDEX('/',@string) > 0 BEGIN SET @len = LEN(@string) SET @i = CHARINDEX('/', @string) SET @object_id = LEFT(@string, @i-1) INSERT INTO temp_table (stid) VALUES (@object_id)--少做修改,改成需要的sql语句即可 SET @string = RIGHT(@string, @len - @i) END select * from temp_table。
答:函数: 1、从左开始截取字符串 left(str, length) 说明:left(被截取字段,截取长度) 例:select left(content,200)...详情>>