点晴模切ERP-sql函数split用于动态校验导入数据
当前位置:点晴教程→点晴ERP企业管理信息系统
→『 经验分享&操作答疑 』
![]() ![]() /****** Object: UserDefinedFunction [dbo].[split] Script Date: 2025/7/7 16:05:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE function [dbo].[split](@SourceSql varchar (max),@StrSeprate varchar (10)) returns @temp table( F1 nvarchar (MAX),SPLIT_ID int) as begin declare @start_i int, @row_id int set @row_id=1; set @SourceSql = rtrim(ltrim(@SourceSql)) --去掉左右空格 set @start_i = charindex( @StrSeprate,@SourceSql ) --查询过滤字符首次出现位置 while @start_i >=1 begin insert @temp values (left(@SourceSql,@start_i - 1),@row_id) set @row_id=@row_id+1; set @SourceSql =substring( @SourceSql, @start_i + len(@StrSeprate), len(@SourceSql) - (@start_i + len(@StrSeprate) - 1)) --去掉已经插入表中的值 set @start_i =charindex( @StrSeprate,@SourceSql ) end if @SourceSql <>'' insert @temp values ( @SourceSql,@row_id) set @row_id=@row_id+1; return end GO 点晴模切ERP更多信息:http://moqie.clicksun.cn,联系电话:4001861886 该文章在 2025/7/9 15:53:39 编辑过 |
关键字查询
相关文章
正在查询... |