MS SQL Server命令行SQLCMD

 

SQL Server命令行导入:

 

sqlcmd -S "localhost" -U "sa" -P "sa" -d "qz_mpsp" -i "C:\Users\Administrator\Desktop\abc.sql"

 

注意通过sqlcmd命令导入时,insert会出现如下问题:

 

当insert脚本为:INSERT INTO t_oco_buyer_drug_supplier_ctrl (buyer_id, drug_id, supplier_id, status, memo, his_sync_status) VALUES ('5018052', 'X01365650010030', '3014041', '0', NULL, '10');

 

会出现导入失败,提示:消息 207,级别 16,状态 1


MS SQL Server命令行SQLCMD
 

 

修改为如下即可(列名不能用双引号

INSERT INTO t_oco_buyer_drug_supplier_ctrl (buyer_id, drug_id, supplier_id, status, memo, his_sync_status) VALUES ('5018052', 'X01365650010030', '3014041', '0', NULL, '10');

 

 

 

但执行时,会出现错误(因执行的SQL脚本有47W行数据)提示【资源池 'default' 没有足够的系统内存来运行此查询。

 

解决方式,在每行【;】结尾处下一行新增【go】

 

INSERT INTO t_oco_buyer_drug_supplier_ctrl (buyer_id, drug_id, supplier_id, status, memo, his_sync_status) VALUES ('5018052', 'X01365650010030', '3014041', '0', NULL, '10'); 

go

INSERT INTO t_oco_buyer_drug_supplier_ctrl (buyer_id, drug_id, supplier_id, status, memo, his_sync_status) VALUES ('5018053', 'X01365650010030', '3014041', '0', NULL, '10'); 

go

 

 

链接:

 

http://blog.163.com/llsh2010@126/blog/static/1691895692011615113838734/

 

http://blog.csdn.net/leamonjxl/article/details/6428753

 

http://blog.csdn.net/zhangyulin54321/article/details/8002941

你可能感兴趣的:(sql,server)