How to concatinate 2 columns from a table

Posted by Rrana under Sql Server on 9/2/2011 | Points: 10 | Views : 1638 | Status : [Member] | Replies : 8
Hi,


How to concatinate 2 columns from a table

Ex:- Table Data

Id Fname Lname Location

1 Raghu Goud Hyd
2 Suchi Sake Atp


Output

1 RaghuGoud Hyd
2 SuchiSake Atp


Thanks in Advance

Sucharitha Goud
Bank Of America..



Responses

Posted by: Kunalverma31 on: 9/2/2011 [Member] Starter | Points: 25

Up
0
Down
you can direct concatenate using below command.

select cast(Id as varchar(20))+ Fname +Lname+Location As Abc from table

Rrana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seenuvasan on: 9/2/2011 [Member] Starter | Points: 25

Up
0
Down
Hi

Try this


select Id , Fname+Lname as fullname ,Location from Data


Thanks,
Seen

Rrana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 9/2/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Try this . . .

Select Id, Fname+Lname,Location From Data


Best Regard's
Prabhakar

Rrana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Niladri.biswas on: 9/5/2011 [Member] Platinum | Points: 25

Up
0
Down
Try this

Declare @t table(Id int identity,FName varchar(10),LName varchar(10),Location varchar(10))

Insert into @t
Select 'Raghu','Goud','Hyd' Union All
Select 'Suchi','Sake','Atp'


-- For all version of Sql Server
Select 

Id
,ConcatName = FName + LName
,Location
From @t


-- Denali(Sql 11) Ctp 3 specific
Select 

Id
,ConcatName = Concat(FName,LName)
,Location
From @t


Output
-----------



Id	ConcatName	Location

1 RaghuGoud Hyd
2 SuchiSake Atp

Let me know if this helps

Thanks

Best Regards,
Niladri Biswas

Rrana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 9/30/2011 [Member] Starter | Points: 25

Up
0
Down

SELECT (FIRSTNAME +LASTNAME) AS NAME FROM EMPLOYEE

SELECT (FIRSTNAME + '/' +LASTNAME) AS NAME AS EMPLOYEE


Hope this will help....
pls feel free any dought..

sriram.r
988 440 2756

sriram

Rrana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 10/27/2011 [Member] Starter | Points: 25

Up
0
Down

Select ID ,FirstName+LastName as Yourname ,Location from Employee


Hope this will Help..

Let me know any quesitons

Sriram.R

sriram

Rrana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Varung on: 12/5/2011 [Member] Starter | Points: 25

Up
0
Down
select Id, Fname || Lname || Location from table name

G.Varun

Rrana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Varung on: 12/5/2011 [Member] Starter | Points: 25

Up
0
Down
SELECT Id, CONCAT(Fname ,Lname,Location ) FROM table name

G.Varun

Rrana, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response