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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Add 2 string fields
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Zath
Constraint Violating Yak Guru

USA
298 Posts

Posted - 03/07/2007 :  09:26:46  Show Profile  Visit Zath's Homepage  Reply with Quote
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)

Singapore
17689 Posts

Posted - 03/07/2007 :  09:32:47  Show Profile  Reply with Quote

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



KH

Go to Top of Page

harsh_athalye
Flowing Fount of Yak Knowledge

India
5581 Posts

Posted - 03/07/2007 :  09:37:09  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
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

USA
298 Posts

Posted - 03/07/2007 :  09:48:07  Show Profile  Visit Zath's Homepage  Reply with Quote
Thanks!

Exactly what I was trying to do.

Zath
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000