问题描述
我们有2个桌子桌子:ApplePhone和AppleGear
桌面结构:ApplePhone
Id电话
1 6s
2 7s
桌面结构:AppleGear
Id Gear
1耳朵
2手表
现在我们需要将上面的表数据写入平面文件中分隔符。
2 O / p文件应该是:
ApplePhone.dat
Id |电话
1 | 6s
2 | 7s
AppleGear.dat
Id | Gear
1 |耳朵
2 |观看
如果有人已经有代码片段,请帮助我们。
我尝试了什么:
到目前为止我们提出了这个代码:
We have 2 tables Tables : ApplePhone and AppleGear
Table Structure:ApplePhone
Id Phone
1 6s
2 7s
Table Structure:AppleGear
Id Gear
1 ear
2 watch
Now we need to write the above table data into flat files with | delimiter.
2 O/p File should be:
ApplePhone.dat
Id|Phone
1|6s
2|7s
AppleGear.dat
Id|Gear
1|ear
2|watch
Please help us with this if anyone has already has a code snippet.
What I have tried:
So far came up with this code:
$SQLServer = 'myServer';
$Database = 'AppleDB';
$SqlQuery = @'
Select Id,Phone FROM [AppleDB].[dbo].[ApplePhone]
'@;
现在不知道怎么办。这个脚本世界的新手。
Don't know how to proceed now. Newbie to this scripting world.
推荐答案
现在不知道怎么办。这个脚本世界的新手。
Don't know how to proceed now. Newbie to this scripting world.
这篇关于如何使用PowerShell从SQL Server将数据写入平面文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!