ALTER FUNCTION atp_MakeCodeList
(
-- Add the parameters for the function here
@liststr nvarchar(4000)
)
RETURNS
@result TABLE
(
code nvarchar(255)
)
AS
BEGIN
-- Fill the table variable with the rows for your result set
declare @cindex int;
declare @newcode nvarchar(255);
declare @newliststr nvarchar(4000);
set @newliststr = @liststr;
set @cindex = charindex( ',', @newliststr );
while( @cindex > 0 )
begin
set @newcode = substring( @newliststr, 1, @cindex - 1 );
insert into @result values( @newcode );
set @newliststr = right( @newliststr, len(@newliststr) - @cindex );
set @cindex = charindex( ',', @newliststr );
end
insert into @result values( @newliststr );
RETURN
END
SqlServer 函数 分割字符串并返回
最新推荐文章于 2023-10-17 15:06:34 发布