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
 Transact-SQL (2000)
 varchar variable in a UDF

Author  Topic 

ckuo@kahluadesigns.com
Yak Posting Veteran

58 Posts

Posted - 2005-04-22 : 17:08:08
I have a udf that returns a varchar(2000)

in the udf i go


Declare @Temp varchar(2000)
SELECT @Temp = COALESCE(@Temp + ', ', '') + CONVERT(varchar,bleh.id)
FROM bleh INNER JOIN blah ON bleh.a = blah.a
WHERE
bleh.id = @id

return @temp


Now when i run this in query analyzer and SELECT @temp, it gets chopped off at 255 chars, when i do PRINT @temp, it displays everything. How can I get this to work in a UDF? I tried to change the varibale to a text, but error says cant use TEXT for a local variable. Any ideas?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-04-22 : 17:09:57
The chopping off at 255 chars has to do with Query Analyzer default settings. Go to tools..options..results tab. Change the maximum characters per column to 7000.

Tara
Go to Top of Page

ckuo@kahluadesigns.com
Yak Posting Veteran

58 Posts

Posted - 2005-04-22 : 17:15:45
Well, in my .net application, it gets chopped off at 255 chars. how would i enable that to accept more?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-04-22 : 17:17:27
Your variable in your application must not be big enough then.

Tara
Go to Top of Page
   

- Advertisement -