SQL JOB (Operating system (CmdExe))

Hi Friends,

I have created a job with (Operating system (CmdExe)),

I have below scenario

If table TABLE_A has records then only execurte this exe. I am not in the position of hardcoding the Database Name.

could you please provide the way to perform this

Sample Psudo code in want to implement in that JOB. I am not allowed to use XP_COMMANDSHELL here. so i am not in the position of making his job as T-SQL .

If exists (SELECT * FROM table_A)
BEGIN
"c:\SomeExecutable.exe"
END

I know this is kind of confusing. Please do the needful.

Thanks in Advance

Parixitsinh

July 3rd, 2013 1:42am

I assume you have appropriate access to create cmdexe job.

job step 1: check your table for existence of rows. On successful of step 1 go to step 2

job step 2: Call your exe.

If exists ( select top 1 * from sys.objects)
Begin
Print 'Records Exists - -> go to exe calling step which is 2nd step '
end
Else
Begin
Print ' Here to go to third step to notify no records exists or no exe call'
End

Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2013 2:00am

Hi

This Sounds like a job for a VB.Net Console Application. or a console application in some .Net language

You said "I am not allowed to use XP_COMMANDSHELL here. so i am not in the position of making his job as T-SQL ."

This VB.Net Console Application could take the table name as a parameter, query the database to see if data is there and then shell out and run the "c:\SomeExecutable.exe"

If this job is going to be run automatically as a Windows scheduled Job you will possibly need to investigate security issues, I don't see how you could run it as a sql server scheduled Job, Possibly through SSIS. but I am not sure.

Dick

July 3rd, 2013 2:10am

HI Srinivasan,

i guess, we cannot write SQL script with Operating system (CmdExe))  JOBS.

IF yes , Please provide the way to do it.

Please do the needful.

Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2013 2:14am

HI,

Unfortunately the Exe is already created and not accepting any parameter, we are not in the position to change the exe.

July 3rd, 2013 2:16am

Yes, the first step should be TSQL, 2nd one is cmdexe.
Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2013 2:25am

Hi Srinivasan

could u please give and example,

How to achive this in SQL JOb. Appritiated if provided steps.

July 3rd, 2013 2:35am

Hi

If you cannot run xp_cmdshell, I think it is doubtful they will let you run and operating system command from a SQL Job.

Though technically that would work.

Dick

Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2013 3:09am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics