Solved

Correct SQL syntax for an expression

Posted on 2008-06-10
2
246 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

734 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