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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select 2 columns as 1, based on values in columns? (samples) 1

Status
Not open for further replies.

DSect

Programmer
Joined
Sep 3, 2001
Messages
191
Location
US
I have 2 columns: Title_A and Title_B

In each row, Title_A or Title_B may be NULL, but both columns will never have NULL on the same row.


How can I return a singular "Title" column in a SQL Server 2K Stored Procedure?

Sample of table data:
tblsample.gif


Sample of desired output:
outputsample.gif


Proper normalization would solve this, but I need to do this on this existing system, as is.

I'd like to see a T-SQL solution, otherwise I'd have to do it in ASP.

Thanks in advance!
 
Code:
[Blue]SELECT[/Blue] [Fuchsia]Coalesce[/Fuchsia][Gray]([/Gray]Title_A[Gray],[/Gray] Title_B[Gray])[/Gray] 
   [Blue]FROM[/Blue] YourTable
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
Thank you!

Wouldn't have known about that function!!

Going to try it in my solution now.

Thanks for the prompt response!
 
how do you get the pics in the post ?

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
I just did a comp-up in access then pshopped it to make it look like the sample and output data.

Used the
 
can you only incude images from a web surver - what about off a hard drive ?

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
Not possible - without fixed IP address (OK, dynDNS more-less) and web server installed.

When necessary, you can use some free image hosting services (a la zippyimages) and link uploaded images from there.
 
My pc has a fixed IP address - what would be the syntax to use ?

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
Are you sure? I'm not talking about local/LAN address...

 
well I think it is - if it is what would be the syntax

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
This goes slightly off-topic but anyway...

In that case you must have web server listening to that address, plus file available under web server's tree. Syntax would be [ignore] ip address here>/<web server path to file here>[/ignore].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top