Solved

HTML in database query

Posted on 2008-06-20
6
162 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

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 discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now