SQL_B2BProjesi_1_MetinParcala_Function
USE [Tiger] GO /****** Object: UserDefinedFunction [dbo].[MetinParcala] Script Date: 04.10.2018 16:03:58 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION [dbo].[MetinParcala] ( @Metin NVARCHAR(MAX), @Ayrac NVARCHAR(MAX) ) RETURNS @AyrismisTablo TABLE ( ID INT IDENTITY(1,1), AyrilmisMetin NVARCHAR(MAX) ) AS BEGIN DECLARE @Sayac INT SET @Sayac = 1 DECLARE @Index INT SET @Index = CHARINDEX(@Ayrac,@Metin) WHILE (@Index>0) BEGIN INSERT INTO @AyrismisTablo (AyrilmisMetin) SELECT AyrilmisMetin = LTRIM(RTRIM(SUBSTRING(@Metin, 1, @Index - 1))) SET @Metin = SUBSTRING(@Metin, @Index + DATALENGTH(@Ayrac) / 2, LEN(@Metin)) SET @Sayac = @Sayac + 1 SET @Index = CHARINDEX(@Ayrac, @Metin) END INSERT INTO @AyrismisTablo (AyrilmisMetin) SELECT AyrilmisMetin = LTRIM(RTRIM(@Metin)) RETURN END GO
0 Yorum