Solved

HTML in database query

Posted on 2008-06-20
6
165 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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 142

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

803 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