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

S 2

Status
Not open for further replies.

Jimmy24

IS-IT--Management
Sep 7, 2006
21
US
Dear Sir or Madam,

I have the following SQL queries that I need to schedule to run every night via SQL Enterprise Manager. Would you please provide me an advise how is the best way to do it? I appreciate your help in advance.

Jimmy

UPDATE gltran
SET gltran.user1 = apdoc.user1
FROM dbo.APDoc INNER JOIN
dbo.GLTran ON dbo.APDoc.RefNbr = dbo.GLTran.RefNbr
WHERE (dbo.GLTran.[Module] = 'AP') and Left
(gltran.acct,3)= '731' ;

UPDATE gltran
SET gltran.user3 = apdoc.user5
FROM dbo.APDoc INNER JOIN
dbo.GLTran ON dbo.APDoc.RefNbr = dbo.GLTran.RefNbr
WHERE (dbo.GLTran.[Module] = 'AP') and Left
(gltran.acct,3)= '731'

Thanks

Jimmy

 
Create a scheduled job in the SQL Server Agent.

- Paul
- If at first you don't succeed, find out if the loser gets anything.
 
It would be a great courtesy to everyone here if you would choose an appropriate title for your post. Even if you get the help you need, a forum full of "S" and "Need Help" and "SQL Problem" isn't very useful to the next visitor here who may have the same question as you.

[COLOR=#aa88aa black]Cum catapultae proscriptae erunt tum soli proscript catapultas habebunt.[/color]
 
Dear Sir or Madam, Do i need to write a store procedure first or just the queries....

Jimmy
 
you can put your statements right in the job step.
From EM just right click on the jobs folder in SQL Server Agent and select new job.
When you add the new job step make sure you get the databaes correct. Then add a schedule for your job.

- Paul
- If at first you don't succeed, find out if the loser gets anything.
 
Mr. Paul,

SInce both queries are pointing the same database can I place both queries just the way I described below or I need to add something else at the beginning such as exe etc. I appreciate your advice.

UPDATE gltran
SET gltran.user1 = apdoc.user1
FROM dbo.APDoc INNER JOIN
dbo.GLTran ON dbo.APDoc.RefNbr = dbo.GLTran.RefNbr
WHERE (dbo.GLTran.[Module] = 'AP') and Left
(gltran.acct,3)= '731' ;


UPDATE gltran
SET gltran.user3 = apdoc.user5
FROM dbo.APDoc INNER JOIN
dbo.GLTran ON dbo.APDoc.RefNbr = dbo.GLTran.RefNbr
WHERE (dbo.GLTran.[Module] = 'AP') and Left
(gltran.acct,3)= '731'

 
You can put them in just the way you have them in your post.

- Paul
- If at first you don't succeed, find out if the loser gets anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top