Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

help, no success using any method of sending this complex string to file

$
0
0

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] WHERE
act_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




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>