Solved

Correct SQL syntax for an expression

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

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.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

821 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