NCS Logo - Click for home page Northstar Developer Center
Platforms
All Platforms
.NET Framework (1.x - 4.x)
Active Server Pages
ASP.NET
C#
SQL Server
VB.NET
Visual Basic

Keywords
.NET Data Types
.NET E-mail
.NET Events
.NET Functions
.NET Object Programming
.NET System.Configuration
.NET System.Diagnostics
.NET System.IO
.NET System.Net
.NET System.Net.Sockets
Active Data Objects
ASP Architecture
ASP Black Belt
ASP Built-in Functions
ASP Built-in Objects
ASP Debugging
ASP Performance
ASP Security
ASP Syntax
ASP.NET Authentication
ASP.NET Controls
ASP.NET Data Access
ASP.NET Features
ASP.NET Master Pages
ASP.NET Page Events
ASP.NET Security
ASP.NET ViewState
Atom
Certifications
COM, DCOM, COM+
Data Access
E-Mail
Errors
Exporting Data
HTML Tips
IIS
Object-Oriented Programming
RSS
SQL
Uncategorized ASP Tips
VB API Programming
VB Forms
VB Syntax
XML

Book Support
Visual Basic 6 Bible
ASP Bible
ASP Weekend Crash Course
ASP.NET At Work
Creating Web Services

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