Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/03/2011, 09:03
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, 9 meses
Puntos: 774
Respuesta: Reemplazar una cadena tomando un inicio y un fin en SQL

Prueba con esto :)


Código SQL:
Ver original
  1. CREATE TABLE #temp(
  2. dato VARCHAR (MAX)
  3. )
  4.  
  5. INSERT INTO #temp (dato) VALUES ('<SPAN STYLE="display:none">Mucho texto ingresado </SPAN><!--texto -->')
  6.  
  7. SELECT stuff(dato,pos1+long,pos2-long-1,'texto a cambiar') FROM
  8. (
  9. SELECT
  10. patindex('%<SPAN STYLE="display:none">%',dato) pos1, patindex('%-->%',dato)pos2, dato, len('<SPAN STYLE="display:none">') long  
  11. FROM #temp
  12. )t1

Regresa esto:

<SPAN STYLE="display:none">texto a cambiar-->


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