09/10/2014, 10:05
|
| Colaborador | | Fecha de Ingreso: agosto-2006 Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 18 años, 4 meses Puntos: 774 | |
Respuesta: Separar cadena de caracteres con Store procedure
Código SQL:
Ver original/****** Object: UserDefinedFunction [dbo].[SplitApplication] Script Date: 10/19/2010 15:12:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION [dbo].[SplitApplication](@applicationid VARCHAR(2000)) RETURNS @RtnValue TABLE ( Id INT IDENTITY(1,1), DATA nvarchar(100) ) AS BEGIN DECLARE @Cnt INT, @SplitOn nvarchar(5) SET @SplitOn = '##' SET @Cnt = 1 While (Charindex(@SplitOn,@applicationid)>0) BEGIN INSERT INTO @RtnValue (DATA) SELECT DATA = ltrim(rtrim(SUBSTRING(@applicationid,1,Charindex(@SplitOn,@applicationid)-1))) SET @applicationid = SUBSTRING(@applicationid,Charindex(@SplitOn,@applicationid)+1,len(@applicationid)) SET @Cnt = @Cnt + 1 END INSERT INTO @RtnValue (DATA) SELECT DATA = ltrim(rtrim(@applicationid)) RETURN END GO how TO USE : SELECT * FROM TABLE WHERE DATA IN ( )
quizas esto te sirva
__________________ What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me |