0

I need to let the server automatically run a query everyday and save the result in .CSV format. But I don't have SQL Server Database Engine since I am using SQL Server Express version. I know that if I have SQL Server Agent, I am able to schedule a job. However, due to our company policy, we are not allowed to install a SQL Server engine on our server. Is there any way to work around it?

My initial idea is using PowerShell to connect the database, run my query and save in CSV then use windows task manager to schedule run the PowerShell script? Or there is any better way? Like Visual Studio?

Any thoughts are much appreciated.

vonPryz
  • 22,996
  • 7
  • 54
  • 65
Lily
  • 3
  • 1
  • 1
    PS script with task manager is really simple. You will need a service account though. – Sid May 24 '19 at 17:19
  • @RohinSidharth Thank you for replying. What service account do I need? – Lily May 24 '19 at 17:32
  • 1
    Look up [Task Scheduler](https://learn.microsoft.com/en-us/windows/desktop/taskschd/task-scheduler-start-page) and see an example for [running Powershell](https://stackoverflow.com/q/23953926/503046) scripts with it. – vonPryz May 24 '19 at 18:41

1 Answers1

0

PS script with task manager is the simplest way to go. however, you will need a service account to set up the task.

I assume you need the task to run whether a user is logged on or not. A service account in the simplest form is a domain account that is not tied to any users. That way, your task will not fail when your password changes or expires or ur account gets deleted (in the event that you leave the company). You can specify to use a domain account in the general tab after creating your task.

enter image description here

Sid
  • 2,586
  • 1
  • 11
  • 22