Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


NTEXT data truncated when run from an Server Agent Job


NTEXT data truncated when run from an Server Agent Job

Author
Message
Andy sql
Andy sql
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1150 Visits: 1301
I am mystified by a problem when handling NTEXT data in SQL Server 2005 SP3. I often have to query 3rd-party stored procedures (which I cannot edit). I usually grab data from these SPs using an INSERT-EXEC.

In this case, the select statement returns an NTEXT field. Usually I insert this straight into nvarchar(max) without a problem. This works fine from a Query window.

BUT..... when the exact same code is run as an SQL Server Agent Job, the NTEXT data is truncated to 512 characters (which I guess equals 1024 bytes). To work around this, I changed nvarchar(max) to NTEXT, but the same problem occurs. This code sets up an example:

create table aaaNtextLog(
LogID int identity(1,1) primary key not null,
Param01 int,
Param02 nvarchar(max)
)
go

create procedure aaaNtextSelect
as
select cast(replicate('123456789 ',250) as ntext)
go

create procedure aaaNtextInsert
as
declare @tblNtext table (Param05 ntext);
insert into @tblNtext(Param05) exec aaaNtextSelect;
insert into aaaNtextLog(Param01, Param02) select len(cast(Param05 as nvarchar(max))), Param05 from @tblNtext;
go



When the SP is run from a Query Window
exec aaaNtextInsert;
select * from aaaNtextLog;


the resulting data is 2499 characters in length. But, when the exact same code is run as a step in an Agent Job, the data is truncated to 512 characters.

Any ideas?????? I have run the code as the same user which SQL Server Agent runs as, so I am fairly sure this is not the problem.

Andy
Ramesh Saive
Ramesh Saive
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2564 Visits: 2643
I've verified your sample and its indeed truncating the result to 512 characters. I think SQL Agent's default TEXTSIZE is 1024, whereas SSMS' default size is 2147483647. So, you should try setting the TEXTSIZE option in the procedure itself. I tried myself and its working.

--Ramesh


Andy sql
Andy sql
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1150 Visits: 1301
Hi Ramesh,

First off, thanks very much for investigating! And you are exactly right, specifying
SET TEXTSIZE { number }
within the Step of the Agent Job solves the problem. Fantastic, many thanks Hehe

Andy
Ramesh Saive
Ramesh Saive
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2564 Visits: 2643
AndyD (1/15/2009)
Hi Ramesh,

First off, thanks very much for investigating! And you are exactly right, specifying
SET TEXTSIZE { number }
within the Step of the Agent Job solves the problem. Fantastic, many thanks Hehe

Andy


Thanks for the feedback and I'm glad I could help you...SmileSmile

--Ramesh


karsten.jacques
karsten.jacques
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 374
Thank you Ramesh. Did the trick.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search