Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/05/2011, 14:42
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: Paso Parametros string procedimiento almacenado

Prueba creando esta funcion:

Código SQL:
Ver original
  1. ALTER FUNCTION [dbo].[SplitApplication](@applicationid VARCHAR(2000))
  2.  
  3. RETURNS @RtnValue TABLE
  4. (
  5. Id INT IDENTITY(1,1),
  6. DATA nvarchar(100)
  7. )
  8. AS
  9. BEGIN
  10. DECLARE @Cnt INT, @SplitOn nvarchar(5)
  11. SET @SplitOn = ','
  12. SET @Cnt = 1
  13.  
  14. While (Charindex(@SplitOn,@applicationid)>0)
  15. BEGIN
  16. INSERT INTO @RtnValue (DATA)
  17. SELECT
  18. DATA = ltrim(rtrim(SUBSTRING(@applicationid,1,Charindex(@SplitOn,@applicationid)-1)))
  19.  
  20. SET @applicationid = SUBSTRING(@applicationid,Charindex(@SplitOn,@applicationid)+1,len(@applicationid))
  21. SET @Cnt = @Cnt + 1
  22. END
  23.  
  24. INSERT INTO @RtnValue (DATA)
  25. SELECT DATA = ltrim(rtrim(@applicationid))
  26.  
  27. RETURN
  28. END
  29.  
  30. GO
  31.  
  32.  
  33. how TO USE :
  34.  
  35. SELECT * FROM TABLE WHERE DATA IN (SELECT DATA FROM SplitApplication(@application))

Lo que hace es que le mandas una cadena separada por comas y la acomoda para que puedas usarla en un "IN"

Saludos!!!
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me