Click here to Skip to main content
15,885,141 members
Home / Discussions / Database
   

Database

 
GeneralRe: mysql decimal fromat like ##.## Pin
Gilbert Consellado22-Nov-14 13:43
professionalGilbert Consellado22-Nov-14 13:43 
GeneralRe: mysql decimal fromat like ##.## Pin
Shweta N Mishra23-Nov-14 2:06
professionalShweta N Mishra23-Nov-14 2:06 
GeneralRe: mysql decimal fromat like ##.## Pin
Gilbert Consellado24-Nov-14 12:47
professionalGilbert Consellado24-Nov-14 12:47 
QuestionProblem in Insering Long text in mysql from c# Pin
Ramachandra12720-Nov-14 7:09
Ramachandra12720-Nov-14 7:09 
GeneralRe: Problem in Insering Long text in mysql from c# Pin
PIEBALDconsult20-Nov-14 7:33
mvePIEBALDconsult20-Nov-14 7:33 
QuestionSQL Replace Function - error recognizing two or more strings Pin
miss78617-Nov-14 23:44
miss78617-Nov-14 23:44 
AnswerRe: SQL Replace Function - error recognizing two or more strings Pin
Richard Deeming18-Nov-14 2:53
mveRichard Deeming18-Nov-14 2:53 
GeneralRe: SQL Replace Function - error recognizing two or more strings Pin
miss78618-Nov-14 3:53
miss78618-Nov-14 3:53 
Thank you very much for your reply and help.

I have already tried the above approach and unfortunately, it gives me incorrect output.

I pass the following XML Input to the UDF:
<Body><p align="justify">One is a 1m block of AIREM 2006-1X 2A3, which has never appeared on SMO.<p></Body> 

the function above, outputs the following (which is incorrect).
One is a &#163;1m block of <a href="<a href="pagename.aspx?tag=<a href="<a href="pagename.aspx?tag=<a href="<a href="pagename.aspx?tag=<a href="<a href="pagename.aspx?tag=<a href="<a href="pagename.aspx?tag=AIREM 2006-1X 2A3">AIREM 2006-1X 2A3</a>"><a href="<a href="pagename.aspx?tag=AIREM 2006-1X 2A3">AIREM 2006-1X 2A3</a></a>"><a href="<a href="pagename.aspx?tag=<a href="<a href="pagename.aspx?tag=AIREM 2006-1X 2A3">AIREM 2006-1X 2A3</a>"><a href="<a href="pagename.aspx?tag=AIREM 2006-1X 2A3">AIREM 2006-1X 2A3</a>

The desired output should be :
<Body><p align="justify">One is a 1m block of <a href="pagename.aspx?tag=AIREM 2006-1X 2A3">AIREM 2006-1X 2A3</a>, which has never appeared on SMO.<p></Body> 


I have attached an example of my dataset in the following link below, for further reference as to what my dataset types are.
http://sqlfiddle.com/#!6/96cac8/2

I looked into a cursor approach for this replace function and have come up with the following below. However, I am still experiencing the same output error, as explained above. the function loops through continuously and creates duplicate names of hyperlinks, within the XML data.
SQL
ALTER FUNCTION [dbo].[ReplaceTags2](@XML VARCHAR(MAX)) 
RETURNS VARCHAR(MAX) 
AS 
BEGIN 

DECLARE @Name VARCHAR(MAX) 
DECLARE CUR CURSOR FAST_FORWARD FOR
SELECT name
FROM [dbo].[database_tags]
Where UploadDate >= '2014-09-01'
and  @XML LIKE '%' + Name + '%' 

OPEN CUR

WHILE 1 = 1
BEGIN
FETCH cur INTO @name 
 --IF @Name IS NOT NULL 
 IF @@fetch_status <> 0 
      BREAK 
 BEGIN 
 SELECT  @XML = REPLACE(@XML, 
   @Name, 
   '<a href="<a href="pagename.aspx?tag='+@Name+'">'+@Name+'</a>') 
 END 
--FETCH NEXT FROM CUR INTO @Name
END

CLOSE CUR;
DEALLOCATE CUR;


 RETURN @XML 
 END 


Please advice further, if possible.
Thank you for your help and time.
GeneralRe: SQL Replace Function - error recognizing two or more strings Pin
Richard Deeming18-Nov-14 6:00
mveRichard Deeming18-Nov-14 6:00 
GeneralRe: SQL Replace Function - error recognizing two or more strings Pin
PhilLenoir18-Nov-14 10:41
professionalPhilLenoir18-Nov-14 10:41 
GeneralRe: SQL Replace Function - error recognizing two or more strings Pin
miss78620-Nov-14 1:45
miss78620-Nov-14 1:45 
GeneralRe: SQL Replace Function - error recognizing two or more strings Pin
PhilLenoir20-Nov-14 3:13
professionalPhilLenoir20-Nov-14 3:13 
AnswerRe: SQL Replace Function - error recognizing two or more strings Pin
PhilLenoir18-Nov-14 3:41
professionalPhilLenoir18-Nov-14 3:41 
Questionsuggest various tables for shopping site Pin
smart_vikas12-Nov-14 18:53
smart_vikas12-Nov-14 18:53 
AnswerRe: suggest various tables for shopping site Pin
Jörgen Andersson12-Nov-14 19:59
professionalJörgen Andersson12-Nov-14 19:59 
AnswerRe: suggest various tables for shopping site Pin
Mycroft Holmes12-Nov-14 22:40
professionalMycroft Holmes12-Nov-14 22:40 
QuestionRe: suggest various tables for shopping site Pin
Eddy Vluggen13-Nov-14 7:18
professionalEddy Vluggen13-Nov-14 7:18 
AnswerRe: suggest various tables for shopping site Pin
PIEBALDconsult13-Nov-14 7:35
mvePIEBALDconsult13-Nov-14 7:35 
QuestionLONGTEXT not accepting large text! Pin
Jassim Rahma12-Nov-14 9:15
Jassim Rahma12-Nov-14 9:15 
AnswerRe: LONGTEXT not accepting large text! Pin
PIEBALDconsult12-Nov-14 9:20
mvePIEBALDconsult12-Nov-14 9:20 
GeneralRe: LONGTEXT not accepting large text! Pin
Jassim Rahma12-Nov-14 9:51
Jassim Rahma12-Nov-14 9:51 
AnswerRe: LONGTEXT not accepting large text! Pin
Richard Deeming12-Nov-14 9:55
mveRichard Deeming12-Nov-14 9:55 
GeneralRe: LONGTEXT not accepting large text! Pin
Jassim Rahma12-Nov-14 9:59
Jassim Rahma12-Nov-14 9:59 
GeneralRe: LONGTEXT not accepting large text! Pin
Richard Deeming12-Nov-14 10:03
mveRichard Deeming12-Nov-14 10:03 
GeneralRe: LONGTEXT not accepting large text! Pin
Jassim Rahma12-Nov-14 10:08
Jassim Rahma12-Nov-14 10:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.