I have SQL querry that I want to run on a scheudle ever other day

Gary Henry 1 Reputation point
2025-09-29T21:23:17.39+00:00

Hi

Not sure if this is the right place to ask so if not I hope someone can direct me...

I have a simple sql query that was written for me (see below) that I now need to run on a schedule and export the data to a .CSV file with Headers and save it so I can use it in another process. It looks like I can do this in poweshell but I do not know how to take the below script and either reference the script itself or put the script into powershell.

I only have ReadOnly access to the SQL database.

I can run this from the management console, but I have the need now to automate the process

USE lc_V3

SELECT

   Items.iID AS product_id,

   LTRIM(RTRIM(s.ProductNumber)) AS mpn

FROM Items

LEFT JOIN POS..Skus s ON Items.strSku = s.Sku

WHERE ISNULL(LTRIM(RTRIM(s.ProductNumber)), '') <> '';

Any help guidance or direction would be welcome

Gary

SQL Server Database Engine
0 comments No comments

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    9 deleted comments

    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.