html - How do I loop through a stored procedure within a sql statement -


i know sounds old question, haven't been able solve problem after reading endless answers, i'll try specific. have table column of text, includes html tags. need remove of html leave some. i've written following code that:

      declare @start int = 1;   declare @end int = 1;   declare @length int = 0;   declare @keep int = 0;   declare @replacechar varchar(10) = '';   declare @offset int = 0;   return;    while @start > 0 , @end > 0     begin       set @replacechar = (select case when substring(@htmltext,@start + 1, 7) in ('/strike')                                       ('</strike>')                                       when substring(@htmltext,@start + 1, 6) in ('strike')                                       ('<strike>')                                       when substring(@htmltext,@start + 1, 4) in ('br /')                                       ('<br />')                                       when substring(@htmltext,@start + 1, 3) in ('/th', '/tr','/td','th ')                                       ('<' + substring(@htmltext,@start + 1, 3) + '>')                                       when substring(@htmltext,@start + 1, 2) in ('th', 'tr', 'td')                                       ('<' + substring(@htmltext,@start + 1, 2) + '>')                                       when substring(@htmltext,@start + 1, 2) in ('/p', '/i', '/b')                                       ('<' + substring(@htmltext,@start + 1, 2) + '>')                                       when substring(@htmltext,@start + 1, 1) in ('p', 'i', 'b')                                       ('<' + substring(@htmltext,@start + 1, 1) + '>')                                       else ''                                  end);       set @keep = (select case when substring(@htmltext,@start + 1, 7) in ('/strike') 1                                when substring(@htmltext,@start + 1, 6) in ('strike') 1                                when substring(@htmltext,@start + 1, 4) in ('br /') 1                                when substring(@htmltext,@start + 1, 3) in ('/th', '/tr', '/td') 1                                when substring(@htmltext,@start + 1, 2) in ('th', 'tr', 'td') 1                                when substring(@htmltext,@start + 1, 2) in ('/p', '/i', '/b') 1                                when substring(@htmltext,@start + 1, 1) in ('p', 'i', 'b') 1                                else 0                           end);        set @htmltext = rtrim((ltrim(stuff(@htmltext,@start, @length,@replacechar))));       set @start = charindex('<', @htmltext,@start + @offset);       set @end = charindex('>', @htmltext,charindex('<', @htmltext,@start + @offset));       set @length = (@end - @start) + 1;        set @offset = @start + @keep;      end;    return @htmltext; 

this needs applied details column in following code, after replace functions have completed.

declare @region  nvarchar(12) = '11' declare @location nvarchar (1000) = '1932' declare @ipm nvarchar (500) = '1594,1611,1934' -- 1932 --'8055,15591'--for 1941 declare @notefromdate datetime = '20150101' declare @notetodate datetime= '20160701'   select r.regionname     , l.locationname     , case when o.currentlocationid <> l.locationid            '*'            else ''       end notcurrentlocation     , e.displayname ipm     , ec.displayname counselor     , oni.offenderid     , an.lastname + ', ' + an.firstname + coalesce(' ' + an.middlename,                                         '') offendername     , oni.notedate     ,replace(replace(replace(replace(         ono.details,'''',''),'&nbsp;',' '),'&amp;',' & '),'rsquo;','-')     ref.employee e     inner join ref.location l       on e.locationid = l.locationid     inner join ref.region r       on l.regionid = r.regionid     inner join ind.offendernoteinfo oni       on e.employeeid = oni.staffid     inner join ind.offender o       on oni.offenderid = o.offenderid     inner join ind.offendernote ono       on oni.offendernoteinfoid = ono.offendernoteinfoid     inner join ind.offendernoteinfo_contactmode onicm       on oni.offendernoteinfoid = onicm.offendernoteinfoid     inner join ind.aliasname       on oni.offenderid = an.offenderid , an.aliasnametypeid = 0 --default name     left join ind.offendercurrentfactpart ocfp       on o.offenderid = ocfp.offenderid     left join hsn.counselorassignment ca       on ocfp.pricounselorassignmentid = ca.counselorassignmentid     left join ref.employee ec       on ca.employeeid = ec.employeeid     e.locationid in (       select value         vnfa.udf_fnsplit(@location, ',')) , e.employeetypeid = 106 --treatment program supervisor       , oni.notetypeid = 11 --facility notes       , onicm.contactmodeid = 229 --institution fidelity review       , (oni.notedate >= @notefromdate , oni.notedate <= @notetodate) , e.employeeid in (       select value         vnfa.udf_fnsplit(@ipm, ','));  

how code section 1 run within code section two?

input details column might like:

<p style="margin: 0in 0in 0pt;"><span style="font-family: calibri;">all areas reviewed </span></p> 

output should be:

<p>all areas reviewed</p> 

i'm not seeing way combine these 2 each row. suggestions.

i others suggest , write code in language. can tsql however. first code can scalar function can applied details column in query.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -