在SQL Server中执行文本文件 [英] Execute text file in sql server
问题描述
海,
我有一个文本文件.这是sql server脚本文件.如果我复制并粘贴到sql server中,并且运行它,它将运行正常.该脚本具有"GO"语句.
我正在使用SqlCommand cmd = new SqlCommand从查询执行的同一文件(我以字符串形式获取)(字符串,sqlconnection).这给出了错误.错误是"GO附近的语法错误".因此,假设我删除了GO,它将正常工作.因此,请指导我如何在不删除"GO"语句的情况下通过查询在sql服务器中执行文本文件.
提前致谢.
Hai,
I have one text file. This is the sql server script file. If i copy and paste in sql server and if i run it it will work fine. This script has "GO" statement.
The same file (i am getting as string) I am executing from query using SqlCommand cmd=new SqlCommand (string, sqlconnection). This is giving error. The error is "Syntax error near GO". So suppose if i removed GO it will work fine. So please guide me how to execute the text file in sql server through query without delete "GO" statement.
Advance Thanks.
推荐答案
您需要在GO
命令上断开脚本.
阅读此内容: http://stackoverflow.com/questions/40814/how-do-i-execute-a-large-sql-script-with-go-commands-from-c [
You need to break the script on theGO
commands.
Read this : http://stackoverflow.com/questions/40814/how-do-i-execute-a-large-sql-script-with-go-commands-from-c[^]
这篇关于在SQL Server中执行文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!