开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜