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 |
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2007-01-22 : 19:10:47
|
I have the sample data...select tbl.*from ( select 1 as a union all select 2 as a union all select 3 as a union all select 4 as a union all select 5 as a ) as tbl what i want is to display this in a single column with a delimeter. On the below example, it is delimeted with a minus sign.select '1-2-3-4-5' as a Want Philippines to become 1st World COuntry? Go for World War 3... |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-22 : 20:43:16
|
[code]declare @a varchar(100)select @a = isnull(@a, '') + convert(varchar(10), a) + '-'from ( select 1 as a union all select 2 as a union all select 3 as a union all select 4 as a union all select 5 as a ) as tblselect @a = left(@a, len(@a) - 1)select @a as a[/code] KH |
 |
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2007-01-22 : 21:29:10
|
tnx khtan. is there another way without using a variable?Want Philippines to become 1st World COuntry? Go for World War 3... |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2007-01-23 : 00:49:31
|
i know this is a wrong forum to ask. because im trying to do that result set in MySQL. That is why I ask without using a variable. Is it possible?Want Philippines to become 1st World COuntry? Go for World War 3... |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-23 : 01:16:13
|
try posting at www.dbforums.com KH |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-23 : 01:26:21
|
Make the concatenation with a UDF.Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|