sql 2005 字符函数实例与应用实例

sql 2005 字符函数实例应用实例

use demo
go
/*
将表code的列string中的值提取放到record表中
string 中字符类型为
dsddddd,2222222,222221,3
其中最后一位为标记对于record表中的biaoji
前面的以’,’分割的是值对应record表中value
*/
go
drop proc proc_split_code
go
create proc proc_split_code
as
begin
set nocount on

declare @count int –条数
declare @index int –变量
set @index = 1 –默认
select @count = count(*) from code
–print @count
while (@indexbegin
declare @biaoji int — 标记
declare @string nvarchar(1000)–字符串
declare @temp int –分隔符的位置
declare @star int –开始位置
declare @code nvarchar(100) —
set @star = 0
select @string=reverse(string)
from (
select row_number() over(order by string) as rownumber,* from code
) as a
where rownumber between @index and @index

set @temp=charindex(‘,’,@string,@star)
set @biaoji = substring(@string,@star,@temp)
print @biaoji
set @string = reverse(@string)
set @temp=charindex(‘,’,@string,@star)
set @star = 0
while(@temp>0)
begin

set @temp=charindex(‘,’,@string,@star)

–print @star
–print @temp

if @temp >0
begin
set @code=substring(@string,@star,@temp-@star)
print @code
–插入到相应的表中
insert into record(biaoji,value,time)
values (@biaoji,@code,getdate())

end
set @star=@temp+1
end

–print @index
print @string
set @index = @index+1
end
end
go

exec proc_split_code

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/1836934.html

(0)
上一篇 2025年2月21日 22:18:15
下一篇 2025年2月21日 22:18:40

AD推荐 黄金广告位招租... 更多推荐

相关推荐

  • php数组值的求和函数是什么

    php数组值的求和函数是“array_sum()”函数,array_sum()函数是PHP数组操作中非常实用的一个函数,它可以方便地计算数组中所有值的总和,并且还可以用于处理二维数组中的某个键对应的所有值的总和。 本教程操作系统:windo…

    2025年2月23日
    100
  • php应用的规范有哪些

    php应用规范有代码风格规范、目录结构规范、使用框架、安全性规范、错误处理规范、性能优化规范、文档规范等。详细介绍:1、代码风格规范有助于团队成员之间的协作,并提高代码的可读性;2、目录结构规范有助于组织代码,并使其易于理解和维护;3、使用…

    2025年2月23日
    100
  • php的输出函数有哪些

    php的输出函数有echo函数、print函数、printf函数、sprintf函数、var_dump函数、print_r函数、die和exit函数等。详细介绍:1、echo函数,用于将字符串、变量或表达式的值直接输出到浏览器;2、prin…

    2025年2月23日
    100
  • php输出内容有哪些函数

    php输出内容的函数有echo函数、print函数、printf函数、var_dump函数和print_r函数等。详细介绍:1、echo函数是PHP中最常用的输出函数之一,它用于将一个或多个字符串输出到浏览器或其他输出设备;2、print函…

    2025年2月23日
    100
  • php中使用什么函数可以得到数组的大小

    php中使用使用`count()`函数、`sizeof()`函数或`array_count_values()`函数可以得到数组的大小。详细介绍:1、count()`函数,创建一个数组,使用count()函数获取数组的大小,输出数组的大小;2…

    2025年2月23日
    100
  • 哪些函数会影响php探针

    影响php探针的函数有ini_set()、error_reporting()、set_time_limit()、memory_limit()、exec()、eval()、disable_functions等等。详细介绍:1、ini_set(…

    2025年2月23日
    100
  • php审计中有哪些危险函数

    php审计中危险函数有eval()函数、exec()函数、system()函数、passthru()函数、preg_replace()函数、unserialize()函数、include()和require()函数、file_get_con…

    2025年2月23日
    100
  • php7弃用的函数有哪些

    php7弃用的函数有mysql_系列函数、ereg_ 系列函数、split()函数、create_function()函数、mcrypt_系列函数和iconv()函数等。详细介绍:1、mysql_系列函数,在PHP7中,mysql_系列函数…

    2025年2月23日
    100
  • php哪些函数可以用来去幂方值

    php可以用来去幂方值的函数有pow函数、双星号、exp函数、sqrt函数和log函数等。详细介绍:1、pow函数用于计算x的y次幂,x是底数,y是指数;2、双星号是幂运算符,用于计算一个数的幂;3、exp函数用于计算以e为底的x次幂,e是…

    2025年2月23日
    100
  • PHP的array_replace()函数用法详解

    在php中,数组是一种非常常见的数据结构。php提供了很多内置的数组函数来进行操作,其中之一就是array_replace()函数。这个函数用于将一个数组中的元素替换为另一个数组中的元素。本文将详解array_replace()函数的用法和…

    编程技术 2025年2月23日
    100

发表回复

登录后才能评论