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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Schedule a job to run T-SQL 1

Status
Not open for further replies.

fafrazh99

MIS
Sep 7, 2002
23
US
I tried to create a job containing only one step. In the first time, the T-SQL script is like this:
Code:
select count(1) from transaction
The job was manually triggered and scheduled to run. It run successfully. In the second time, the script to run is like following:
Code:
use int
go
update transaction
set name = 'good',
addr1 = 'first',
transDate = null
where invalid = 0
go
delete from transaction
where tranDate between '1/1/2002' and '2/1/2002'
go
This time, the job can not be run manually or scheduled.
The error log shows me following message:

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

It seems like my script is too long. Is there any max length I should consider here? Did anybody experience similar problem before?

By the way, I'm using SQL 2K with SP3.

Thanks for your help!

Frank
 
would you mind scripting the table out for us and posting it....
 
The error indicates you are trying to update a column with data that is longer than the column allows. What is the size of the name and addr1 columns? If these columns are large enough to hold the data being inserted then you should look for a trigger on the transaction table that is updating a column more data than the column can hold.

If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Thanks Terry!

The interesting things is when I tried to run the same scripts in Query Analyzer. The table was updated successfully. No warning and error message.

Frank
 
There is an ansi_warnings setting that can be turned off in Query Analyzer. If ansi_warnings is off then the message is not and the date is truncated and inserted. You can check the setting by clicking Query | Current connection properties on the main QA menu.

If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top