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)
 Where I am wrong

Author  Topic 

mdanwerali
Starting Member

30 Posts

Posted - 2002-11-09 : 05:28:53
hi

i have a problem using COALESCE function, where i am wrong... please suggest me, with this query i am not able to store the second or third record details in the variable.... even though this condition satisfies more than one record.
---------------------
DECLARE @topicdesc varchar(8000)

SELECT @topicdesc = COALESCE(@topicdesc + ', ', '') +
CAST(tpmdetails AS varchar(4000))
FROM topicmaster
WHERE tpmtopicid = 'TM00000038' or tpmowner = 'TM00000038'

SELECT @topicdesc

---------------
here i am trying to fetch more than one record into @topicdesc but unfortunately i am not able to see the output of second record.

Means it is fetching only the first records and from second it is omitting. where i am wrong.


md anwer ali

SamC
White Water Yakist

3467 Posts

Posted - 2002-11-09 : 14:04:43
I'd like to see the output of

SELECT CAST(tpmdetails AS varchar(4000))
FROM topicmaster
WHERE tpmtopicid = 'TM00000038' or tpmowner = 'TM00000038'

I assume it has more than 1 row, but seeing is believing.

Sam

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-11-10 : 17:37:11
Also how long are the fields.
Query analyser will default to displaying 256 chars - you can change this in advanced settings.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -