Powershell 截断 SQL 查询输出 [英] Powershell truncating SQL Query Output

查看:36
本文介绍了Powershell 截断 SQL 查询输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 powershell 命令运行以下查询,不幸的是,该命令会截断或在结果字符串的末尾添加点.我已经调整了 powershell 的屏幕缓冲区大小,即右键单击 powershell 属性>布局>屏幕缓冲区大小>宽度和高度设置为 9999(最大值).似乎输出仅限于 powershell 屏幕缓冲区大小,我似乎无法解决这个问题.感谢您的帮助.

I'm running the following query from a powershell command which unfortunately truncates or adds dots to the end of the result string. I had adjusted the screen buffer size for powershell i.e. right click on powershell Properties>Layout>Screen Buffer Size> width and height set to 9999 (max). It seems like the output is limited to the powershell screen buffersize and I can't seem to get around this one. Any help is appreciated please.

Invoke-Sqlcmd -ServerInstance myrds.com -Database mydb -Username dbuser -Password passord -maxcharlength 80000 -Query "SELECT CAST(BINARYCOL AS VARCHAR(MAX)) FROM OLTP_TABLE WHERE ID=123123 AND COMPANYID=123" | Out-File -FilePath "C:\Users\USER\Documents\ps_scripts\res3.txt"

推荐答案

感谢所有回复的人.我在下面制定了一个 bcp 行来让我从 varbinary 到字符串的非截断结果.

Thanks to everyone who's replied. I had formulated a bcp line below to get me the non-truncated result from varbinary to string.

bcp "SELECT CAST(BINARYCOL AS VARCHAR(MAX)) FROM OLTP_TABLE WHERE ID=123123 AND COMPANYID=123" 
queryout "C:\Users\USER\Documents\ps_scripts\res.txt" -c -S myserver.db.com  -U admin -P password

这篇关于Powershell 截断 SQL 查询输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆