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 2008 Forums
 Transact-SQL (2008)
 Combine result in SQL

Author  Topic 

amsad
Starting Member

17 Posts

Posted - 2011-02-17 : 23:37:12
Hi guys,

I need to combine result with 3 column,

Example;

no_id |file_seq_no | group_name |alert_no |
1 3060 die70 0001
2 3061 die70 0001
3 3062 die70 0002

i want to select and create like this output,

no_id | new_column |
1 die70_3060_0001
2 die70_3061_0001
3 die70_3062_0002



Appreciate if you can help me.Thanks






Can do.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-02-17 : 23:43:54
[code]
select new_column = group_name + convert(varchar(10),file_seq_no) + alert_no
[/code]

assuming that file_seq_no is a numeric column


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Ranjit.ileni
Posting Yak Master

183 Posts

Posted - 2011-02-18 : 00:30:46
Try this...

create table #temp
(
no_id int,
file_seq_no int,
group_name varchar(10),
alert_no varchar(10)
)
go
insert #temp
select 1,3060,'die70','0001' union all
select 2,3061,'die70','0001' union all
select 3,3062,'die70','0002'
go

select no_id,new_column = group_name +'_'+ convert(varchar(10),file_seq_no) +'_'+ alert_no
from #temp

--Ranjit
Go to Top of Page

amsad
Starting Member

17 Posts

Posted - 2011-02-18 : 01:46:35
Hi,

I already try on this,its done!

Thank you guys....

Can do.
Go to Top of Page
   

- Advertisement -