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 2005 Forums
 Transact-SQL (2005)
 NEW LINE

Author  Topic 

scottichrosaviakosmos
Yak Posting Veteran

66 Posts

Posted - 2010-09-25 : 03:45:46
select gender,amt,age,[address],class ,

Case when gender= '' then 'gender,'when gender is null then 'gender,' Else '' End +
Case when amt = '' then 'amt,'when amt is null then 'amt,' Else '' End +
Case when age = '' then 'age,'when age is null then 'age,' Else '' End +
case when [address] = ''then 'address'when [address] is null then 'address,' else '' End +
Case when class = '' then 'class,'when class is null then 'class,' Else '' End
As [Error Remarks] from mytable

The above query is used to check if any of this row is blank or null display the result in
a column name "error remarks" .
Now the result i m getting is :
gender, amt, age,address,class
all this result is displayed in a single line in a single cell.
now i want the result to be displayed in different line:
like this:
gender,
amt,
age,
[address],
class

all this is single cell with the above query.

scoo

Sachin.Nand

2937 Posts

Posted - 2010-09-25 : 04:14:04
Post the query you have tried so far.

PBUH

Go to Top of Page

scottichrosaviakosmos
Yak Posting Veteran

66 Posts

Posted - 2010-09-25 : 04:18:03
the above query i pasted is the query . and i have tried char(13),
Char(13)+char(10) also ..
still the result is not comming in next line

scoo
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-09-25 : 04:28:24
Sorry didnt see it.
Easiest way will be to use a union.Maybe it wont be that efficient on a large table.

declare @tbl as table(nm varchar(20),nm1 varchar(20))
insert into @tbl
select 'g','g1'

select case when nm='g' then 'g' else '' end from @tbl
union
select case when nm1='g1' then 'g1' else '' end from @tbl



PBUH

Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-09-25 : 04:49:15
and in between I am sure you will never get back on this to us once you get what you want.
Like you did in your previous posts.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=150413
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=149900
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=149751


PBUH

Go to Top of Page
   

- Advertisement -