Solved

HTML in database query

Posted on 2008-06-20
6
166 Views
Last Modified: 2010-04-21
I am running a simple select statement that outputs records from a clients table returning their ID, First Name and Last Name.

Is there a way to return a link in that table as well, ie, I thought:

select id, alt_id as [Alternate ID], t.first_name as [First Name], t.last_name as [Last Name],
'<a href=https://someurl?id=' & id & '>Link</a>' as Link

would work but it doesn't.
0
Comment
Question by:hyphenpipe
  • 3
  • 2
6 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 21832174
if the link is stored in a field, you just need to mention that column

select id, alt_id as [Alternate ID], t.first_name as [First Name], t.last_name as [Last Name], Link
from urTable
0
 
LVL 6

Author Comment

by:hyphenpipe
ID: 21832229
The link is not stored in a field.
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 21832514
You want to return the same link with all the resultset ?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 6

Author Comment

by:hyphenpipe
ID: 21832772
Say I have a table that only contains:

ID, First_Name, Last_Name

I want the output result to be

http://someurl?id=ID where ID is the ID number from the table.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 21832881
you used & , but SQL uses +
select id, alt_id as [Alternate ID], t.first_name as [First Name], t.last_name as [Last Name],
'<a href=https://someurl?id=' + CAST(id as varchar(20)) + '>Link</a>' as Link 

Open in new window

0
 
LVL 6

Author Closing Comment

by:hyphenpipe
ID: 31469205
Thanks!!!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to extract a "coded date" from a string field? 4 64
How to enforce inte 8 59
Strange msg in the SSMS pane 13 58
Addition to SQL for dynamic fields 6 47
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question