Reputation: 789
I have table(Title varchar,Description varchar).And I bind it to datagrid to use in windows application.But here i want to combine Title,Description and display the result in a single row-cell. If I use like this
Select Names, 'myData' from emp
The output is:
Name1 myData
Name2 myData
Name3 myData
But, I need to display like this in a Single column:
Name1
myData
Name2
myData
Name3
myData
and i want to bind it to datagrid.
How do I do this?
Upvotes: 0
Views: 1651
Reputation: 6489
If you want to combine those column you have to do like following code
Select Name, Family, Name+ CHAR(13) +Family as FullName From Employee
hope this help.
Upvotes: 1
Reputation: 62484
I would not suggest doing such conversion on data base layer, query should return table as long as it possible, so do it in application level, as a case using LINQ:
var transformedItems = items.Select(item => String.Format("{0}{1}{2}",
item.Name,
Environment.NewLine,
item.Description));
Upvotes: 0
Reputation: 65147
Select Names + CHAR(10) + CHAR(13) + 'myData'
from emp
Will put it all in a single column for you at the DB level.
Upvotes: 0
Reputation: 168958
Try
SELECT Names + char(13) + Description FROM emp
This will insert a newline between the two column values and return the result as a single column.
Upvotes: 4