Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Simple Query Problem!

Author  Topic 

mibheenick
Starting Member

12 Posts

Posted - 2004-09-27 : 04:07:06
Hi evryone out there!
First of all Thanx very much for the Urgent replies i got last time out....it was real helpful!

here's another one though :-)

Say i have several Binary columns in a table which can take only values 'O' or 'N'...

I want a select statement which returns me only the NAMES OF THE COLUMNS where the value is 'O' for each row in the table...

I leave it to god.....

Kristen
Test

22859 Posts

Posted - 2004-09-27 : 04:27:08
[code]
SELECT MyPkColumn,
CASE WHEN MyCol1 = 'O' THEN 'MyCol1 ' ELSE '' END
+ CASE WHEN MyCol2 = 'O' THEN 'MyCol2 ' ELSE '' END
FROM dbo.MyTable
WHERE MyCol1 = 'O' OR MyCol2 = 'O'
[/code]
Kristen
Go to Top of Page
   

- Advertisement -