Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Works in Query Analyzer, fails in Server Agent??

Status
Not open for further replies.

Wyldcard9

Programmer
Feb 5, 2004
82
US
Code:
UPDATE [TRUST].[dbo].[Export docs]
SET Thousand=LEFT(ID2, 1),
Folder=RIGHT(ID2, 1),
Sub_Folder=RIGHT(ID2, 3)
WHERE ID2 > 999
and ID2 < 10000

UPDATE [TRUST].[dbo].[Export docs]
SET Sub_Folder=LEFT(Sub_Folder, 2)
WHERE ID2 > 999
and ID2 < 10000

UPDATE [TRUST].[dbo].[Export docs]
SET Thousand='0',
Folder=RIGHT(ID2, 1),
Sub_Folder=LEFT(ID2, 2)
WHERE ID2 > 99
and ID2 < 1000

UPDATE [TRUST].[dbo].[Export docs]
SET Thousand='0',
Folder=RIGHT(ID2, 1),
Sub_Folder=LEFT(ID2, 1)
WHERE ID2 > 9
and ID2 < 100

UPDATE [TRUST].[dbo].[Export docs]
SET Sub_Folder= '0' + Sub_Folder
WHERE Sub_Folder < 10

UPDATE [TRUST].[dbo].[Export docs]
SET Thousand='0',
Folder=RIGHT(ID2, 1),
Sub_Folder='00'
WHERE ID2 < 10

UPDATE [TRUST].[dbo].[Export docs]
SET DOC_COUNT='00'+DOC_COUNT
WHERE DOC_COUNT < 10

UPDATE [TRUST].[dbo].[Export docs]
SET DOC_COUNT='0'+DOC_COUNT
WHERE DOC_COUNT < 100
GO

This code works in SQL Query Analyzer, however under SQL Server Agent jobs it gives me this error:

Executed as user: WPAS-INC\imaging. String or binary data would be truncated. [SQLSTATE 22001] (Error 8152) The statement has been terminated. [SQLSTATE 01000] (Error 3621). The step failed.

The fields in the table being used here are:
Thousand int 4
Folder int 4
Sub_folder varchar 50
DOC_COUNT char 3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top