Files
GX.O3.WMS/WebApi/docs/export_db_bom.ps1
T

12 lines
722 B
PowerShell
Executable File

Add-Type -AssemblyName System.Data
$conn = New-Object System.Data.SqlClient.SqlConnection('server=10.10.10.101;database=GXWMS;uid=sa;pwd=Gx@20240111;Pooling=true')
$conn.Open()
$cmd = $conn.CreateCommand()
$cmd.CommandText = "SELECT ChildMaterialId, ParentMaterialId, UsageQty, Level, MaterialName, Spec FROM Product_BOM_Detail WHERE ProductCode='CG0S175E0000120' AND BOMVersion='V1.2.0.135.00' ORDER BY Level, ChildMaterialId"
$da = New-Object System.Data.SqlClient.SqlDataAdapter($cmd)
$dt = New-Object System.Data.DataTable
$da.Fill($dt) | Out-Null
$dt | Export-Csv -Path 'd:\Code\WMS\WebApi\docs\db_bom2.csv' -NoTypeInformation -Encoding UTF8
Write-Output ("Exported rows: " + $dt.Rows.Count)
$conn.Close()