Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SIMPLE TSQL - RETURN CONCANTENATED

Status
Not open for further replies.

sisieko

Programmer
Jun 13, 2004
56
US
I am trying to write a query (TSQL) in sql server to derive an imageurl for each employee using their empId.

The images are saved as empId.gif (e.g. 0001.jpg) in this location /images/employeephotos/

How do i write the t-sql return a concantenated url of the location if the employee has an image in the folder, else, the url should return a default imageurl of 0000.jpg

I am pretty new to TSQL PLEASE HELP.



 
What you want to do is store the image name in your database, which I assume you have. Then, to display do this:

Code:
select EmployeeName, '[URL unfurl="true"]http://www.somesite.com/images/'[/URL] + isnull(EmployeeImageColumn, '0000.jpg')
from mYTable

You are basically hard coding the URL (except for the image portion). If the image portion is null, then you replace the null with '0000.jpg'.

Make sense?

Hope this helps,

Alex


Ignorance of certain subjects is a great part of wisdom
 
Help!!
What is the correct syntax to subtract weeks from a date.

SELECT TABLE.DATE ADD_MONTHS(T00149.DATECH, 1) "Deadline"

from TABLE.DATE
Thanks

 
Um, start a new thread? And your code does not look like SQL server, are you sure you're in the right forum?

Ignorance of certain subjects is a great part of wisdom
 
Thanks for your help AlexCuse : )
This is the sisieko (the original poster). I was using my friend's id to post, but im registered now.

It works like charm. Thanks buddy!
 
undeclared,

Welcome to tek-tips. To maximize your experience here, I suggest you read this: faq183-874 (especially number 16) [wink]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Glad that it worked Undeclared!

And welcome. I hope you will find tek-tips to be as great a place to learn as I have found it :)

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top