 
 
 delete from _tablas  where  tabla='ort_reporteTecnico_ot'
 
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ValoresMultiples]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[ValoresMultiples]
GO
CREATE Function [dbo].[ValoresMultiples] (@p_ids varchar(8000))
	returns @IDS table (id int) 
AS BEGIN

	DECLARE @NextString NVARCHAR(40)
	DECLARE @Pos INT
	DECLARE @NextPos INT
	DECLARE @String NVARCHAR(40)
	DECLARE @Delimiter NVARCHAR(40)

	SET @String =@p_ids
	SET @Delimiter = ','
	SET @String = @String + @Delimiter
	SET @Pos = charindex(@Delimiter,@String)

	WHILE (@pos <> 0)
	BEGIN
		SET @NextString = substring(@String,1,@Pos - 1)
		insert into @IDS(id)values(@NextString)
		SET @String = substring(@String,@pos+1,len(@String))
		SET @pos = charindex(@Delimiter,@String)
	END 
			
	return   
END

