创建批处理文件以读取,创建和执行脚本(存储过程) [英] Creating a Batch File to read, create and execute scripts(stored procedures)

查看:99
本文介绍了创建批处理文件以读取,创建和执行脚本(存储过程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我尝试了SQLCMD并创建了一个批处理文件

-S = DEVELOPER04代表我的本地服务器
-E =用于可信连接
-d = oMBMIS是我的数据库

KR_REPORTS_manual_insert_script.sql是脚本
该脚本将创建表KR_REPORTS,并使用我在脚本中包含的记录填充该表.

这是批处理文件:
SQLCMD -SDEVELOPER04 -E -doMBMIS -iC:\ mbkSCRIPTS \ KR_REPORTS_manual_insert_script.sql


当我双击批处理文件并在SSMS中检查结果时.没有KR_REPORTS表.
我错过了什么吗?

Hi,

i tried SQLCMD and created a batch file

-S = DEVELOPER04 stands for my Local Server
-E = for trusted connection
-d = oMBMIS is my database

KR_REPORTS_manual_insert_script.sql is the script
this script will create table KR_REPORTS and populate it with records also included in the script i did.

Here''s the batch file:
SQLCMD -SDEVELOPER04 -E -doMBMIS -iC:\mbkSCRIPTS\KR_REPORTS_manual_insert_script.sql


and when I double-click my batch file and check result in my SSMS. There was no KR_REPORTS table.?

Did I miss something?

推荐答案

尝试通过CMD提示符运行它-可能是脚本引发了一个正在报告的问题,但是您丢失了它是因为批处理窗口将立即销毁.
Try running it via a CMD prompt - it may be that the script raises a problem which is being reported, but you are missing it because the batch window is immediately destroyed.


C:\> sqlcmd -S mlk98 \ sqlexpress -d BomAudit -Q"EXEC RefreshFromPDC_PRDSTR"

链接服务器的OLE DB提供程序"Microsoft.Jet.OLEDB.4.0"
"PDCPASSTHRUACCESS"返回消息" J:\ Innovations \ ENGADMIN
\ PDI \ PdcDataAudit \ PdcPassthru.mdb''不是有效路径.确保
路径名称拼写正确并且已连接到
文件所在的服务器.".
消息7303,级别16,状态1,服务器MLK98 \ SQLEXPRESS,过程
vewReadPdc_part_bom,第3行
无法初始化OLE DB提供程序的数据源对象
链接服务器"PDCPASSTHRUACCESS"的"Microsoft.Jet.OLEDB.4.0".

那是我的命令行和产生的错误消息.我在cmd shell和SSMS中都以我自己的身份运行它.
C:\>sqlcmd -S mlk98\sqlexpress -d BomAudit -Q "EXEC RefreshFromPDC_PRDSTR"

OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server
"PDCPASSTHRUACCESS" returned message "''J:\Innovations\ENGADMIN
\PDI\PdcDataAudit\PdcPassthru.mdb'' is not a valid path. Make sure
that the path name is spelled correctly and that you are connected to
the server on which the file resides.".
Msg 7303, Level 16, State 1, Server MLK98\SQLEXPRESS, Procedure
vewReadPdc_part_bom, Line 3
Cannot initialize the data source object of OLE DB provider
"Microsoft.Jet.OLEDB.4.0" for linked server "PDCPASSTHRUACCESS".

That is my command line and the resulting error message. I am running it as myself both in the cmd shell and within SSMS.


我更新了我的批处理文件,它开始运行.

SQLCMD -S DEVELOPER04 \ MBWIN -doMBMIS -iC:\ mbkSCRIPTS \ KR_REPORTS_script.sql
暂停



我检查了oMbMis和KR_Reports表是否已创建并填充了记录..:)
I updated my batch file, and it run.

SQLCMD -S DEVELOPER04\MBWIN -doMBMIS -iC:\mbkSCRIPTS\KR_REPORTS_script.sql
pause



I checked oMbMis and KR_Reports tables is created and populated with records.. :)


这篇关于创建批处理文件以读取,创建和执行脚本(存储过程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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