Zack
asked on
Powershell Problem
Heyas,
I can't get an particular SQL query to export to txt file. The powershell script I have works for all other sql queries and what the script does is export the query results to a txt file.I have administrative rights on my server and below is the sql query.
SELECT
		sysjobs.Name
FROM msdb..sysjobhistory
		INNER JOIN msdb..sysjobs ON msdb..sysjobs.job_id= msdb..sysjobhistory.job_id
I also have error catch statement on my powershell but it never returns any errors.
But I never any get any results back from the server. Is this a security issue any ideas?
Thank you.
I can't get an particular SQL query to export to txt file. The powershell script I have works for all other sql queries and what the script does is export the query results to a txt file.I have administrative rights on my server and below is the sql query.
SELECT
		sysjobs.Name
FROM msdb..sysjobhistory
		INNER JOIN msdb..sysjobs ON msdb..sysjobs.job_id= msdb..sysjobhistory.job_id
I also have error catch statement on my powershell but it never returns any errors.
But I never any get any results back from the server. Is this a security issue any ideas?
Thank you.
Does this work?
Does the code work if you run it against the DB in SQL Management Studio?
USE msdb
SELECT sj.Name
FROM sysjobs As sj
INNER JOIN sysjobhistory As sjh
ON sj.job_id = sjh.job_id
Does the code work if you run it against the DB in SQL Management Studio?
Is it possible one (or both) table(s) are empty?
ASKER
The code works fine SQL Management Studio, just not when I try get the run sql query from the powershell script I created. I have tested the powershell script with other queries I have developed and they work fine.
Thank you.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My apologies for the delay in answering net connection was down.
No problem, it's goo to know your issue is resolved ;)
ASKER