Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CONCAT function

Status
Not open for further replies.

hexOffender

Programmer
Nov 6, 2006
146
US
I am trying to combine th results of these two selects using '+'. It was working before, then it stopped. The individual statements run fine, but when I try to combine them I get an empty result, not a NULL, just an empty result

SELECT distinct Response
FROM NurQueryResults AS NQR
WHERE NQR.VisitID=@VisitID
AND NQR.QueryID = 'NUR.BDAY'+
SELECT STUFF((SELECT distinct Response
FROM NurQueryResults AS NQR
WHERE NQR.VisitID=@VisitID
AND NQR.QueryID = 'NUR.TIME'),3,0,':')+':00.000')
 
Strange query - I'm wondering why it doesn't give you syntax problem.

Try adding ( before second SELECT.

What exactly you're trying to achieve and what is your SQL Server version?

PluralSight Learning Library
 
I need to join a BirthDate and a BirthTime fields into a BirthDateTime (I know, I know... believe me I didnt design it this way ). I have tried it with the Parenthesis, and thats when it gives me the empty result, without the parenz, it gives a syntax error.
 
Can you post DDL of the table, few records as insert and desired result? Are you sure you want to join based on concatenated field or you want to include this concatenated field in your result?

PluralSight Learning Library
 
No I just want to include the concatenated field in my result
 
If that's the case, then

Code:
SELECT distinct Response,'NUR.BDAY' +  STUFF('NUR.TIME'),3,0,':') + ':00.000' as FullDOB
FROM NurQueryResults AS NQR
      WHERE NQR.VisitID=@VisitID


PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top