SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Truncation of data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jparker
Posting Yak Master

118 Posts

Posted - 10/27/2005 :  07:38:19  Show Profile  Reply with Quote
I have the following script

create table tblestimateusage (id_num int IDENTITY(1,1),
est_id varchar(50),
title varchar(200),
flatsize varchar(50),
finishedsize varchar(50),
pages varchar(50),
client_name varchar(150),
process varchar(7000)
)

insert into tblestimateusage (est_id,title,flatsize,finishedsize,pages, client_name, process) select e.est_id, title, flatsize, finishedsize, pages, client_name, [dbo].[ufn_GetProcesses] ( [est_id] ) from tbltest e
join tblcl c on c.client_id = e.client_id
where est_datetime > '20050901'
select * from tblestimateusage

Which uses the following function

ALTER FUNCTION [dbo].[ufn_GetProcesses] ( @ID INT )
RETURNS VARCHAR(6000)
AS
BEGIN

DECLARE @ProcessValue VARCHAR(6000)

SELECT @ProcessValue = ISNULL(@ProcessValue + ', ', '') + [process_name] + ' ' + [process_value]
FROM [dbo].[tblmyprocess]
WHERE [est_id] = @ID

RETURN @ProcessValue

END

This works fine on some occassions but has a problem when either the line hits 8060 bytes then it bombs out or truncating the string via the function.

How do I allow truncation?

spirit1
Cybernetic Yak Master

Slovenia
11749 Posts

Posted - 10/27/2005 :  07:59:26  Show Profile  Visit spirit1's Homepage  Reply with Quote
have your process filed srt to varchar 6000 and not 7000.


Go with the flow & have fun! Else fight the flow
Go to Top of Page

jparker
Posting Yak Master

118 Posts

Posted - 10/27/2005 :  08:10:15  Show Profile  Reply with Quote
sorry my example is a little misleading they should be the same.

The problem arises when the function attempts to add byte 7001 to @ProcessValue. Rather than noticing it can't add any more and simply returning a truncated variable it decides to blow up with a warning. I want it to return that truncated string (which I know and understand to be down to the page file) and wanted to know how to make sql server accept this
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000