Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Add 2 string fields

Author  Topic 

Zath
Constraint Violating Yak Guru

298 Posts

Posted - 2007-03-07 : 09:26:46
I have a select and want to bring back one field as the combination of 2 fields....

Something like:

SELECT a.reportedBy AS 'user',
b.fName,
b.lName

FROM tblReports a,
tblUsers b

WHERE a.reportedBy = b.userId

Now, in the code behind, I can add fname and lname but it would be more efficient to do it in the sql.

Something like

a.reportedBy AS 'user' (user = b.fname + ' ' + b.lname)

Can't find the syntax for this one.

Thanks,

Zath

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-07 : 09:32:47
[code]
SELECT a.reportedBy AS [user],
b.fName + b.lName AS [fullname]
FROM tblReports a INNER JOIN tblUsers b
ON a.reportedBy = b.userId
[/code]


KH

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-07 : 09:37:09
quote:
Originally posted by khtan


SELECT a.reportedBy AS [user],
b.fName + ' ' + b.lName AS [fullname]
FROM tblReports a INNER JOIN tblUsers b
ON a.reportedBy = b.userId



KH





Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Zath
Constraint Violating Yak Guru

298 Posts

Posted - 2007-03-07 : 09:48:07
Thanks!

Exactly what I was trying to do.

Zath
Go to Top of Page
   

- Advertisement -