Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/gwilson/addinginhtmllinks.asp
Interesting idea... I would lean towards applying this type of functionality as a business component of an application versus applying it at the database level. I'm also the guy that likes to put logs on the fire in the "Avoid Cursurs" camp.
I'd agree, probably best to avoid cursors. (Most) anytime you can offload iterative processing from the database into true recursive techniques using a different tool you're going to be better off.
Also, would it be better to use the REPLACE() function rather than PATINDEX()?
Aaron & Jason, thanks for the input.
Aaron, in regards to using the REPLACE() function - I didn't use it in this case, because the field being manipulated is a text, data type field. The REPLACE() function doesn't work on text fields. I generally store most web content in text fields because there is no size limitation.
Jason, I actually like to keep front and Ntier, application coding very generic, and offload complex coding to SQL Server, stored procedures when I can. I do get a lot of criticism for taking that strategy sometimes, but I think it makes life easier for applying application updates. I am a SQL server junkie.
thanks, Grey Wilson
I recently wrote some stored procedures that create hyperlinks, however there was a difference between what I did and what is described in this article.
I had to create hyperlinks to an intranet application, based upon dynamic content of the web page. The data from the database was to be used as an argument to an aspx web page.
Essentially, I used a stored procedure to pull data out of a database and then used .NET to populate the page. I had two choices as to how I displayed certain data fields within hyperlnks...
1. I could get the .NET code behind to do it on the fly. The problem with this was that if the server being linked to changed, someone would have to edit the code behind and re-compile the application. Not desireable as this is a complex application and not written using the normal Visual Studio method (Its written using Unix software development principles if anyone is interested)
2. I could get the stored procedure to output the hyperlinks directly instead of just the data field. This gets round the problem of having to re-compile the application to take account of any changes. The stored procedure is simply amended and re-run in SQL Server. This was beneficial because where I work there is a great deal more SQL server experience than there is Unix-style program development experience.
The way I did this was like this:-
Normal stored procedure snippet...
select mydatafield from mytable
select 'http://myserver.net/mypath.aspx?' +
'myarg=' + mydatafield as 'mydatafield'
Simple! Isn't it?
Viewing 5 posts - 1 through 4 (of 4 total)