Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Scheduled SQL statement not running

Posted on 2010-11-25
3
Medium Priority
?
273 Views
Last Modified: 2012-05-10
Hi Experts,
The below statements run well when starting them manually. When I try to schedule the statements the SQL part does not run.

We use Windows Server 2008 / MS SQL 2008.

Thanks for the help in advance.

Regards,
MB
@echo off
:delfiles
del /q c:\temp\*.*

:runftp
ftp -s:"c:\scripts\HRC_Shipnet.ftp"
rem if errorlevel 0 goto runsql
rem echo Error while downloading HRC Shipnet files
rem net send admin3 "Error while downloading HRC Shipnet files"
rem goto end

:runsql
sqlcmd -i c:\scripts\HRC_Shipnet.sql -b -o C:\scripts\logs\HRC_Shipnet.log
if errorlevel 0 goto end
echo Error while importing data to db
net send admin3 "Error occured while importing HRC Shipnet db"
goto next1

:end

USE ShipNet
GO
TRUNCATE TABLE REP_MAIN
GO
TRUNCATE TABLE REP_PORTS
GO
TRUNCATE TABLE REP_PORTS_BUNKERS
GO
TRUNCATE TABLE REP_PORTS_BUNKERS_SUPP
GO
TRUNCATE TABLE T016_PORT
GO
TRUNCATE TABLE T065_SHIP
GO
TRUNCATE TABLE T580_POSITION
GO
TRUNCATE TABLE T581_POSACTIVITIES
GO

BULK
INSERT REP_MAIN
FROM 'c:\temp\REP_MAIN.csv'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

BULK
INSERT REP_PORTS
FROM 'c:\temp\REP_PORTS.csv'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

BULK
INSERT REP_PORTS_BUNKERS
FROM 'c:\temp\REP_PORTS_BUNKERS.csv'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

BULK
INSERT REP_PORTS_BUNKERS_SUPP
FROM 'c:\temp\REP_PORTS_BUNKERS_SUPP.csv'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

BULK
INSERT T016_PORT
FROM 'c:\temp\T016_PORT.csv'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

BULK
INSERT T065_SHIP
FROM 'c:\temp\T065_SHIP.csv'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

BULK
INSERT T580_POSITION
FROM 'c:\temp\T580_POSITION.csv'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

BULK
INSERT T581_POSACTIVITIES
FROM 'c:\temp\T581_POSACTIVITIES.csv'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

Open in new window

0
Comment
Question by:mark_norge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 34211243
you need to log the error, if any, when it runs scheduled, otherwise it will just be guesswork....
0
 
LVL 6

Expert Comment

by:subhashpunia
ID: 34211605
You need to create an Credential for a windows login that have access in SQL Server. Then create a proxy on that credential. Then use that proxy in Agent job in Run As account.
0
 

Author Closing Comment

by:mark_norge
ID: 34212035
Changing the error log level showed a mistake I was able to fix. Thanks and apologies.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question