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 2005 Forums
 Transact-SQL (2005)
 Concat Strings

Author  Topic 

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-11-29 : 23:25:50
Hi all,
I am retriving a single value from the a sql table using this statement

Select loginname from * where no='1348'

Which produces the following result

danasekarane

Now I want the outut as

d | a | n | a | s | e | g | a | r | a | n | e


How can I..

Thanks in Advance
Dana

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-29 : 23:55:21
you want individual character as separate column or row ?


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

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-30 : 01:28:39
quote:
Originally posted by danasegarane76

Hi all,
I am retriving a single value from the a sql table using this statement

Select loginname from * where no='1348'

Which produces the following result

danasekarane

Now I want the outut as

d | a | n | a | s | e | g | a | r | a | n | e


How can I..

Thanks in Advance
Dana


Where do you want to show the data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-11-30 : 01:51:56
quote:
Where do you want to show the data?

I am trying to show the data in Bound field of a DataReport(VB).

quote:
you want individual character as separate column or row ?

Now I want it in a single value with | inserted between each charters
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-30 : 03:26:18
you can use substring() to extract individual character and concatenate with the '|' character


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

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-30 : 03:31:36
[code]declare @a varchar(100), @b varchar(200)

set @a = 'danasekarane'

Select @b = Coalesce(@b + ' | ', '') + substring(@a, number, 1)
from master..spt_Values
where name is null and number between 1 and datalength(@a)

select @b[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-11-30 : 03:53:55
Thanks Harsh,
Even You spoun feeded me, I am struggling this integrating with my code
Go to Top of Page
   

- Advertisement -