SQLTeam.com | Weblogs | Forums

Hyperlink Column in SQL Table



Is it possible to create a hyperlink column in a SQL Server table? I was hoping to create a column which appears as Y but links through to a website like a normal hyperlink.

I created a test table as follows:

USE MIProcessing
(Hyperlink nvarchar(255),

I then tried to use HTML code within an INSERT INTO statement to add the hyperlink.

INSERT INTO Test (Hyperlink)

However, this actually creates a text output as specified above.

Is there a way for the output in the table to appear as Y but with an active hyperlink that feeds through to a specified URL?

Thanks in advance


There is a good discussion here:


It would be better to do this in your APP / Presentation layer.

However, if your table contains the columns "TextLink" and "HyperLink" you could do

SELECT '<a href="'
       + HyperLink
       + '">'
       + TextLink
       + '</a>'
FROM YourTable

which will give you something like

<a href="http://www.mysite.com/">Y</a>

The problem with it is that the Presentation layer will usually also be responsible for the CSS Style / Class, and all sorts of other "presentation" <Natch!> issues which you don't really want to have to adjust, and re-dploy, the SQL code when they need changing.

If you use HTML Templates in your code then you can probably write something like

Please click <a href="{HyperLink}">{TextLink}</a> to continue

and hook-up that Template to a

SELECT Hyperlink, Textlink from YourTable

to "merge" it with the actual database data