dbo.sp_separo_OR

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

2
Name Data Type Length Description
@Nom varchar -1
@separador varchar 10

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: María Inés Soria
-- Create date: 2017-12-05
-- Description: Ingresa Nombre, devuelve palabras separadas
-- =============================================
-- sp_separo_OR 'SORIA or MARIA or INES or SORIA or MARIA or INES'
CREATE OR ALTER PROCEDURE dbo.sp_separo_OR
@Nom VARCHAR(max), 
@separador varchar(10) = ' OR '
AS
BEGIN
 
 DECLARE @pos               SMALLINT
 DECLARE @len int = (select LEN(@Nom))
 set @pos = (select CHARINDEX(@separador,@nom))
 while @pos != 0 
 begin
  select LTRIM(rtrim(SUBSTRING(@nom,1,@pos)))
  set @nom = SUBSTRING(@nom,@pos+len(@separador),@len)  
  set @pos = (select CHARINDEX(@separador,@nom))
  set @len = (select LEN(@Nom))
 end 
 select LTRIM(rtrim(SUBSTRING(@nom,1,@len)))

END 

GO

Depends On

No items found