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.
| Author |
Topic |
|
dsylebee
Starting Member
8 Posts |
Posted - 2009-11-29 : 14:35:45
|
| Hi everyone id like to know how i can do this.Im binding my table to an object in sql server.so let's say i have 3 fields ( making it easier :o )I haveidfirstnamelastnamewhat i want is to get 4 fields with my selectSELECT id, firstname, lastname, (firstname + space) As fullname + lastname FROM contacts ORDER BY lastnamei don't know how to merge those 2 fields thanks in advance. :) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2009-11-29 : 14:40:21
|
| Not complicated, but this should be done in the presentation layer instead. You should only return firstname and lastname as separate columns and then concatenate them for display in your application.SELECT id, firstname, lastname, firstname + lastname AS fullnameFROM contacts ORDER BY lastnameTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog"Let's begin with the premise that everything you've done up until this point is wrong." |
 |
|
|
dsylebee
Starting Member
8 Posts |
Posted - 2009-11-29 : 14:42:39
|
| "SELECT *, (c_lastname + ' ' + c_firstname) As c_fullname FROM contacts ORDER BY c_lastname"thanks anyways :) |
 |
|
|
dsylebee
Starting Member
8 Posts |
Posted - 2009-11-29 : 14:45:12
|
quote: Originally posted by tkizer Not complicated, but this should be done in the presentation layer instead. You should only return firstname and lastname as separate columns and then concatenate them for display in your application.SELECT id, firstname, lastname, firstname + lastname AS fullnameFROM contacts ORDER BY lastnameTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog"Let's begin with the premise that everything you've done up until this point is wrong."
I would but the listbox from C# only accepts binding context of one field from a dataset so it's way more simple to create a temp field in a record set since i'm using non-queries to store and update my database thanks for your tip. |
 |
|
|
|
|
|
|
|