我试图在call()
或Popen()
:
sqlcmd -E -S .\
USE MASTER
GO
SELECT
name AS [Logical_name],
physical_name AS [File_Path],
type_desc AS [File_Type],
state_desc AS [State]
FROM sys.master_files
WHERE database_id = DB_ID(N'AdventureWorksLT2008_old')
GO
它会引发一些错误。现在,我想看看问题是什么。我制作了命令的.bat文件。我执行了它,只有sqlcmd -E -S .\
被执行。其余部分则没有。如何在python中的cmd之后控制sqlcmd以执行其余的代码?
你能帮忙吗?
感谢
答案 0 :(得分:0)
您需要指定一个输入选项,例如-q
并删除GO
命令。请以read the documentation为例。尝试:
sqlcmd -E -S .\ -q "
SELECT
name AS [Logical_name],
physical_name AS [File_Path],
type_desc AS [File_Type],
state_desc AS [State]
FROM sys.master_files
WHERE database_id = DB_ID(N'AdventureWorksLT2008_old')"
如果需要,或者将它们全部放在一行中。