Hi All,
Before this morning I was completely oblivious to the fact that powershell existed so please excuse the myriad of perhaps obvious questions I need to ask.
I have a problem and I simply cannot solve it through any of my existing tools which is why I have hunted down powershell as a solution but I don’t know how to go about solving said problem with powershell…
I have been looking on the web but it is still completely baffling so I ask for your help in building my understanding of this.
I need to…
Connect to a web server 10.xx.xx.xx
Goto a database schema called “Interactive_Reporting”
run an SQL script (please see below) on the web server this script is called reportpositions.sql
export the results from that query to a network file location L:\Interactive_Reporting
if it could attach the date of this export that would be fantastic also…
The report I need to run at 04:00 am (system time each day) so somewhere I am thinking windows task scheduler will be required also?
Is this possible and if so how would I even go about attempting it?
Thank you in advance for any help…
SO the SQL Script is fairly meaty;
DECLARE @startdate CHAR(8)
DECLARE @finaldate CHAR(8)
SELECT @startdate=CONVERT(CHAR(8),GETDATE()-1,112),
@finaldate=CONVERT(CHAR(8),GETDATE(),112)
Select VL3ADVICE1NUM As “Advice Num”,
VL3advice1num as “Bargain Number”,
VL3CLIENTNUM As “Account”,
CLISHORTNAME2 As “Account Name 1”,
CLISHORTNAME1 As “Account Name 2”,
VL3DEPOTNUM As “Depot”,
DEPNAME1 As “Depot Name 1”,
DEPNAME2 As “Depot Name 2”,
VL3SECURITYNUM As “Security”,
SECDESCRIPTION1 As “Security Name 1”,
SECDESCRIPTION2 As “Security Name 2”,
VL3BROKERNUM As “Broker”,
PARNAME1 As “Broker Name”,
VL3DATE1 As “Trade Date”,
VL3DATE2 AS “Settlement Date”,
VL3certregistereddate AS “Trade Status”,
SUM(CAST(vl2beneficial AS NUMERIC (20,6)) - CAST(vl2settledbalance AS NUMERIC (20,6))) As “Unsettled Quantity”,
VL3certregistereddate AS “Unsettled Consideration”,
vl3consideration As “Consideration”,
vl3currency1 AS “Currency”,
vl3quantity as “Quantity”,
VL3MENUNUM As “Transaction Type”,
vl3currency1 AS “Country Of Register”,
VL3BROKERCOMMISSION AS “Broker Commission”,
VL3TIMESTAMP AS “Timestamp”
from t5vaultsl3 inner join t5client
on t5vaultsl3.vl3clientnum = t5client.clicode
INNER JOIN T5DEPOT
ON T5VAULTSL3.VL3DEPOTNUM = T5DEPOT.DEPNUM
INNER JOIN T5SECURITY
ON T5VAULTSL3.VL3SECURITYNUM = T5SECURITY.SECSECURITYNUM
INNER JOIN T5PARTICIPANT
ON T5VAULTSL3.VL3BROKERNUM = T5PARTICIPANT.PARPDRPARTICIPANTID
inner join t5vaultsl2
On T5VAULTSL3.vl3clientnum = t5vaultsl2.vl2clientnum And T5VAULTSL3.VL3SECURITYNUM = t5vaultsl2.vl2securitynum And T5VAULTSL3.vl3depotnum = t5vaultsl2.vl2depotnum
WHERE VL3DEPOTNUM IN (‘COFUNDNOMINE’, ‘COFUNDWRAP’, ‘WBSWRAP’)
AND LEFT(VL3timestamp,8) >= ‘20140203’
(VL3timestamp,8) Between @Startdate And @Enddate ’
AND VL3MENUNUM NOT LIKE ‘830’
AND VL3MENUNUM NOT LIKE ‘232’
AND VL3MENUNUM NOT LIKE ‘369’
AND VL3MENUNUM NOT LIKE ‘341’
AND VL3MENUNUM NOT LIKE ‘831’
GROUP BY VL3ADVICE1NUM, VL3CLIENTNUM, CLISHORTNAME2, CLISHORTNAME1, VL3DEPOTNUM, DEPNAME1, DEPNAME2, VL3SECURITYNUM, SECDESCRIPTION1, SECDESCRIPTION2,
VL3BROKERNUM, PARNAME1, VL3DATE1, VL3DATE2, VL3BROKERCOMMISSION, VL3TIMESTAMP, VL3CONSIDERATION, VL3REPORTCONSIDERATION, VL3CURRENCY1,
VL3CURRENCY2, VL3CURRENCY3, VL3QUANTITY, VL3MENUNUM, VL3CERTREGISTEREDDATE