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 2000 Forums
 SQL Server Development (2000)
 Change attribute(column) to string

Author  Topic 

iswan
Starting Member

28 Posts

Posted - 2007-06-08 : 07:25:33

Is it possible to convert single column value to string? (with out using cursor or while loop) i.e Is Any Aggregate function available?

I have seen SettoStr() function. But It is not working in SQL server 2000.

Ex:
create proc
as
declare @FieldNam varchar(1024)
select @FieldNam=Name from Project
PRINT @FieldNam
end


select statement return multiple row output. But I am only getting first value in PRINT. I know If I use cursor or while loop can construct the string. But I want to know any other way with out this

Coming Output: ProjectOne

Needed Output: ProjectOne,ProjectTwo,PRojectThree..

Regards
Iswan


harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-08 : 07:30:24
[code]Select @FieldNam = Coalesce(@FieldNam + ',','') + Name from Project
Print @FieldNam[/code]

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

iswan
Starting Member

28 Posts

Posted - 2007-06-08 : 07:38:06
Thank you very much Harsh Athalye
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-09 : 07:44:58
Also note that if the concatenated string exceeds 8000 characters, you need to use more than one variable

Madhivanan

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

- Advertisement -