Using SQL Server for String Processing
Written by Eric Smith, Northstar Computer Systems LLC
If you’re not aware, VBScript in ASP is relatively slow when it comes to string manipulation. If you’re doing a lot of string “stitching” using data from a database like SQL Server, let the server do more of the work for you. Here’s a quick example of this in action. This stored procedure is designed to retrieve the name and URL of a bunch of web sites that are stored in a database table. Instead of having ASP put the URL together with the name, I let SQL Server do it in the stored procedure. In fact, the only thing that ASP has to do is to loop through the records and print out the value of the WebSite field. Add a UL tag to the top and bottom and I’ve got a bulleted list of web sites. Here’s the stored procedure code for it:
CREATE Procedure sp_RetrieveClientSites As
SELECT
' <a href="http://' + RTrim(URL) + '">' + RTrim(Name) + '</a>' As WebSite
FROM tblClientSites
WHERE IsActive = 1
Order By Name
You can see it in action at this URL:
<a href="http://www.northcomp.com/res_clients.asp">http://www.northcomp.com/res_clients.asp</a>
Keywords: [
Uncategorized ASP Tips
]
Publication Date: 4/1/2000
|