?
Solved

I have a select query that I would like to add string data to

Posted on 2010-01-03
7
Medium Priority
?
248 Views
Last Modified: 2013-12-17
I would like to have my query return the following

SELECT  dirID, name, email,  http://www.details.aspx?dirID={ + dirID + } AS qs
FROM  directors

I get an error when I try this.  How can I create this http query string as a result in my query?

Sample of the query Im trying to create

http://www.details.aspx?dirID={0}
0
Comment
Question by:bmanmike39
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 10

Accepted Solution

by:
lof earned 1200 total points
ID: 26167161
You have to use quotation marks and convert dirId to varchar

SELECT  dirID, name, email,  'http://www.details.aspx?dirID={' + convert(varchar(max),dirID) + '}' AS qs
FROM  directors

Hope it helps
Lo
0
 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 800 total points
ID: 26167163
I assume dirID is int (or any other numeric type). You need to convert that into varchar to append it:

SELECT  dirID, name, email,  'http://www.details.aspx?dirID={' + convert(varchar, dirID) + '}' AS qs FROM  directors

0
 

Author Comment

by:bmanmike39
ID: 26167207
This is what i have I still got an error.

I used single and double quotation marks

SELECT  dirID,  email,  '"http://www.details.aspx?dirID={'" + convert(varchar(max),dirID) + '"}'" AS qs
FROM  directors
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:tigin44
ID: 26167210
just convert the dirID to varchar and then append it to the string.



SELECT  dirID, name, email,  'http://www.details.aspx?dirID={' + CAST(dirID AS varchar) + '}' AS qs
FROM  directors
0
 
LVL 26

Expert Comment

by:tigin44
ID: 26167212
try my post as given
0
 

Author Closing Comment

by:bmanmike39
ID: 31672190
Thanks  it works , fond a typo first time i ran it.
0
 
LVL 10

Expert Comment

by:lof
ID: 26167229
You need to use single quotation marks in SQL, double ones are meaningless
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

830 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