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)
 Returning long string in varchar using Coalesce

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-05-09 : 08:39:53
Ashish writes "Hi,

I want to return a string of words separated by comma using coalesce() so that the client application can look for a specific word in this long string.Following is the script:-


CREATE TABLE WordList
(
WordId int IDENTITY,
WordDesc varchar(100)
)

INSERT INTO WordList VALUES ('Lion')
INSERT INTO WordList VALUES ('Goat')
INSERT INTO WordList VALUES ('Snake')


DECLARE @WordList varchar(8000)
SELECT @WordList = COALESCE(@WordList + ', ', '') + WordDesc
FROM WordList
SELECT @WordList AS WordList


Above approach works fine.However,as the maximum size for varchar is 8000,any longer string will be truncated.I can not use "text" datatype for this as it is not allowed.
Any workaround?Any pointers?"

nr
SQLTeam MVY

12543 Posts

Posted - 2006-05-09 : 10:13:08
Why not get the app t send the word and look for it in the SP.
Maybe use varchar(max) if you are v2005?

==========================================
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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-10 : 04:11:41
Search for 8000 in this topic
http://sqlteam.com/forums/topic.asp?TOPIC_ID=55210

Madhivanan

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

- Advertisement -