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 |
|
chava_sree
Yak Posting Veteran
56 Posts |
Posted - 2008-08-12 : 21:42:46
|
| How do i concantenate two table rows in a view.. I am trying to do this.TABLE 1------- T_ID,FIRSTNAME,LASTNAME,CITY,SCHOOLTABLE 2-------T_ID,DEPARTMENT,FACULTY NAME,SUBJECTI want to concatenate FIRSTNAME + LASTNAME + DEPARTMENT + SUBJECT as one string.. SELECT T1.FIRSTNAME + ' ' + T1.LASTNAME + '' + T2.DEPARTMENT + T2.SUBJECT FROM T1 Inner join T2 ON T1.T1_ID = T2.T2_IDthis doesn't work.. |
|
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-08-12 : 22:58:43
|
| If I have understood your tables, Table 1 seems to be Student & Table2 seems to be subject. Do you want all students against every subject? If so this is a CROSS JOIN. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-13 : 00:14:41
|
quote: Originally posted by chava_sree How do i concantenate two table rows in a view.. I am trying to do this.TABLE 1------- T_ID,FIRSTNAME,LASTNAME,CITY,SCHOOLTABLE 2-------T_ID,DEPARTMENT,FACULTY NAME,SUBJECTI want to concatenate FIRSTNAME + LASTNAME + DEPARTMENT + SUBJECT as one string.. SELECT T1.FIRSTNAME + ' ' + T1.LASTNAME + '' + T2.DEPARTMENT + T2.SUBJECT FROM T1 Inner join T2 ON T1.T1_ID = T2.T2_IDthis doesn't work..
What doesn't work ?Any error message ? You are not getting the required result ? You have NULL in one of the column ?Please explain. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-13 : 00:18:03
|
change like this and try if it worksSELECT COALESCE(T1.FIRSTNAME + ' ','') + COALESCE(T1.LASTNAME + '','') + COALESCE(T2.DEPARTMENT,'') + COALESCE(T2.SUBJECT,'') FROM T1 Inner join T2 ON T1.T1_ID = T2.T2_ID |
 |
|
|
|
|
|
|
|