Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

New to SQL server

$
0
0

I have SQL statements our ERP support people sent me to handle a multiple jobs issue we have since they upgraded us.

Basically what happens is the system will submit 1 or 2 jobs thousands of times, but it doesn't happen consistently.

-- to prevent any possible issues run this in transaction, so when something goes wrong 
-- you can rollback the whole update
begin tran

-- run this statemetn to get 'IN_PROCESS' task(s)
select pkey,shelldesc,* from zzxrptsc
where cstatus = 'IN_PROCESS'

-- update the task status to 'FAIL' that you want to stop
update	zzxrptsc 
  set	cstatus = 'FAILED' 
where pkey = -- enter pkey from previous query

-- if this is a recurring task you would need to disable it as well:
update	zzxrptsc 
  set	cstatus = 'FAILED', cactive = 'N'
where pkey = -- enter pkey from the 1st query
 
-- rollback chnages if you have to
rollback

-- commit chnages if you get desired results and everything is correct
commit

The main question is whats 'begin tran' and where do I run it.

Do I start a new query?

How do I sent this job up as a loop because I have to UPDATE thousands jobs and I don't want to be entering the pkey value everytime.

Thanks

Michael


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>