Solved

Correct SQL syntax for an expression

Posted on 2008-06-10
2
247 Views
Last Modified: 2010-04-21
I am having difficulty creating an expression as part of an SQL Select query in MS SQL 2000. The expression should generate a URL. I have already done for variables that do not include a number, but now have difficulty.

The question is in the code snippet as follows.
I want to create the following URL:-
<a href="admin/doc.asp?id=Num">Text</a>      
where Num is from an int field varID, and Text is from an nvarchar field. Both from a table tblxyz.
 
The following attempt does not work:-
 '<a href="admin/doc.asp?id=' + STR(dbo.tblxyz.varID) + '''>' + dbo.tblxyz.varTitle + '</a>' AS DocURL
 
Grateful for correct coding! Thanks

Open in new window

0
Comment
Question by:pcardwell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
CMYScott earned 500 total points
ID: 21756086
have you tried something like..

'<a href="admin/doc.asp?id=' + CAST(dbo.tblxyz.varID AS varchar(20)) + '">' + dbo.tblxyz.varTitle + '</a>' AS DocURL
0
 

Author Closing Comment

by:pcardwell
ID: 31465983
Just tried it and it works perfectly. Thanks!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

705 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