【发布时间】:2021-08-13 17:59:08
【问题描述】:
我想从特定数据库的所有表中获取数据。 我在 sql 中生成了一些 BCP 语句。现在我需要使用 c# 中的批处理文件从 Windows 服务执行这些 bcp 语句。
我有以下 bcp 语句:
bcp [MyDB].[dbo].[tbl_UserLocations] out c:\temp\dbo_tbl_UserLocations.txt -S dbinstance.cvxlgn3jt61m.us-east-1.rds.amazonaws.com -U adminusername -P adminpassword -c
bcp [MyDB].[dbo].[tbl_UserTypes] out c:\temp\dbo_tbl_UserTypes.txt -S dbinstance.cvxlgn3jt61m.us-east-1.rds.amazonaws.com -U adminusername -P adminpassword -c
帮助表示赞赏。
【问题讨论】:
-
为什么不使用 GetSchema? docs.microsoft.com/en-us/dotnet/api/…
-
为什么是批处理文件,为什么不直接来自 C# 的
Process.Start -
能否提供一个示例代码来从 C# 执行 bcp 命令?
标签: c# sql-server windows-services bcp