Can you not do this:

SELECT     ISNULL(Col1, Col2) AS PopulatedCol
FROM         TABLENAME

HTH
Paul

Paul Broomfield
NEOCOM Ltd
50 Dalton Street
Napier
New Zealand

Tel +64 06 8355534
WebSite http://www.neocom.co.nz

-----Original Message-----
From: Bostrup, Tore [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, 01 October 2002 10:28 a.m.
To: ActiveServerPages
Subject: RE: SQL Help Needed

|| is the concatenation operator in ORACLE.  With SQL Server you have to use
+.  Other than that, beware of NULLs.

If one column is null, concatenating them will yield NULL regardless of the
content in the other one.  In that case, use:

SELECT CASE 
        WHEN Col1 Is Null THEN Col2
        ELSE Col1 END as aliasname
FROM ELEMENT ORDER BY aliasname

HTH,
Tore.


-----Original Message-----
From: Jesse Quijano [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 30, 2002 6:13 PM
To: ActiveServerPages
Subject: OT: SQL Help Needed


First disclaimer:  The database structure comes from a VERY well known 
document/imaging company - I didn't make the mess, I'm just trying to work 
with it. :)

I have a table that contains two fields with the same type of data 
(Reference Number), but one was used for older documents, and one was used 
for newer documents.  I want to sort on and display the two fields as one 
(only one will be populated for any given record).  I talked to my local 
Oracle guru here at work and he's given me a syntax like so:

SELECT Col1 || Col2 aliasname FROM ELEMENT ORDER BY aliasname

It seems perfect, however I'm using a SQL Server, and it's not having any 
part of that syntax.  Does anyone know of a similar way to accomplish this 
task in SQL Server 2000?

Any help is appreciated!
Thanks,
Jesse
http://www.qbstech.com/mycode


---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to