0
 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.

1

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.