I am using powershell to build sql to manipulate data in tables. it works but instead of copy/paste the output into a file from the console, I want to output to a file. The output line includes strings and variables containing datetime etc. the strings are the sql code and the variables are data that has to be quoted for sql. example:
If
( $J_start -eq "IS NULL" ) {
Write-Host act_start $eekwulS $s_start AND act_end $eekwulE "'$s_end'" AND finish_status = "'$finish_status'" AND sla_id = "'$sla_id'"
}
Elseif
( $J_end -eq "IS NULL" ) {
Write-Host act_start $eekwulS "'$s_start'" AND act_end $eekwulE $s_end AND finish_status = "'$finish_status'" AND sla_id = "'$sla_id'"
}
Else
{
Write-Host act_start $eekwulS "'$s_start'" AND act_end $eekwulE "'$s_end'" AND finish_status = "'$finish_status'" AND sla_id = "'$sla_id'"
}
If ( $LR -lt $load_data.Count) {
Write-Host OR
}
}
example of console output:
select * from [ITO_SLA_QA].[dbo].[SLA_Actual] WHEREact_start = '11-06-2013 00:00:15.000' AND act_end = '11-06-2013 02:07:45.000' AND finish_status = 'G' AND sla_id = 'BSLA140000'
OR
act_start = '11-06-2013 03:00:17.000' AND act_end IS NULL AND finish_status = 'R' AND sla_id = 'BSLA140001'
OR
act_start = '11-06-2013 02:30:21.000' AND act_end = '11-06-2013 03:50:07.000' AND finish_status = 'G' AND sla_id = 'BSLA140002'
Thanks