user704401
user704401

Reputation: 139

In Tsql, how do i replace a value if the value is not null?

For a directory, I want the words "visit website" to appear only if the member has entered a website. I do not want to retrieve the actual web site url.

Replace and Coalesce seem to work only if the value is null.

This is certainly not working

SELECT replace (eweb,'website','website') as value 
from Web_FacStaffdir 
where eweb is not null

Upvotes: 1

Views: 4119

Answers (1)

Luke Baughan
Luke Baughan

Reputation: 4686

Something like:

SELECT CASE WHEN LEN(eweb) > 0 THEN 'website' ELSE '' END as value
from Web_FacStaffdir 
where eweb is not null

Upvotes: 3

Related Questions