September 25, 2010 at 1:45 am
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.
September 25, 2010 at 2:27 am
You could add char(10) +char(13) (CR/LF) after each CASE part.
However, SSMS will not display it correctly in grid mode, only in text mode. I'm not sure what tool you'll use to display the results.
Case when gender= '' then 'gender,'when gender is null then 'gender,' Else '' End + char(10) +char(13)+
Case when amt = '' then 'amt,'when amt is null then 'amt,' Else '' End +char(10) +char(13)+
Case when age = '' then 'age,'when age is null then 'age,' Else '' End +char(10) +char(13)+
case when [address] = ''then 'address'when [address] is null then 'address,' else '' End + char(10) +char(13)+
Case when class = '' then 'class,'when class is null then 'class,' Else '' End
As [Error Remarks] from mytable
September 25, 2010 at 4:30 am
yes, i have used char(13) but its still not showing result in new line
the problem is that i m using this value in a dataset for exporting in excel so i have to get value from sql servr in resultset.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply