Select Sql Query from 2 column into one column
empid empname empDOB
1 kiran 23-11-1987
2 manu 25-4-1999
now i need to write 1 single query where empname and empDOB as single value
empid Emp
1 kiran,23-11-1987
2 manu ,25-4-1999
i need the output like this
can anyone please tel me the syntax开发者_开发知识库 how to do it.
You can concatenate the values together like this:
SELECT empid, ISNULL(empname, '') + ',' + ISNULL(empDOB, '') AS emp
FROM YourTable
If empDOB is a DATETIME field, you could do this which will format the date in the format you've given:
SELECT empid, ISNULL(empname, '') + ',' + ISNULL(CONVERT(VARCHAR(10), empDOB, 105), '') AS emp
FROM YourTable
精彩评论