[英]No way to execute SQL script from SQL Server Query Manager like @{file.sql} oracle sqlplus syntax?
Like the title says, in oracle you can issue the following command in SQL*Plus: 就像标题所说,在oracle中你可以在SQL * Plus中发出以下命令:
SQL> select something from anothertable; #sql
SQL> @{/home/me/somescript.sql}; #load sql from file and execute it
SQL> do something else in script; #other sql
Without having to file->open the sql script to load it to the UI. 无需文件 - >打开sql脚本将其加载到UI。
Is there an equivalent in SQL Server Query Manager? SQL Server查询管理器中是否存在等效项? I've stumbled upon many situation where i could have used it but i couldn't be able to find a way to accomplish it.
我偶然发现了许多情况,我可以使用它,但我无法找到实现它的方法。
You're not really comparing like for like Tools here. 你不是真的在这里比较类似的工具。
The equivalent tool to SQL*Plus in SQL Server is the SQLCMD Utility . SQL Server中与SQL * Plus等效的工具是SQLCMD实用程序 。
In particular you will be interested in the -i switch as this allows you to provide a .sql file as input. 特别是你会对-i开关感兴趣,因为这允许你提供一个.sql文件作为输入。
Edit: 编辑:
In response to your comment, you could look to use the system stored procedure xp_cmdshell to launch a prompt form within a T-SQL batch that allows you to use SQLCMD. 在回复您的注释时,您可以使用系统存储过程xp_cmdshell在T-SQL批处理中启动提示表单,以允许您使用SQLCMD。 Not the most elegant solution in my opinion but it should work.
在我看来,这不是最优雅的解决方案,但它应该有效。
If using latter versions of SQL Server (2005 & 2008), see if the :r
command in SQLCMD works for you: 如果使用后者版本的SQL Server(2005和2008),请查看SQLCMD中的
:r
命令是否适合您:
:r <filename> Parses additional Transact-SQL statements and sqlcmd commands from the file specified by <filename> into the statement cache. :r <filename>将<filename>指定的文件中的其他Transact-SQL语句和sqlcmd命令解析到语句高速缓存中。 If the file contains Transact-SQL statements that arenot followed by GO, you must enter GO on the line that follows :r.
如果文件包含GO不遵循的Transact-SQL语句,则必须在以下行中输入GO:r。 From sqlcmd Utility
来自sqlcmd Utility
还有一些SQLS * Plus工具可用于在脚本中执行脚本
Use isql utility http://msdn.microsoft.com/en-us/library/aa214007(SQL.80).aspx 使用isql实用程序http://msdn.microsoft.com/en-us/library/aa214007(SQL.80).aspx
issql ... -iinputfile issql ... -ininputfile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.