怎样用简单的 SQL 语句打开一个脚本文件(与 SQL Server 在同一机器上)并执行它?

怎样用简单的 SQL 语句打开一个脚本文件(与 SQL Server 在同一机器上)并执行它?
请高手指点!
---------------------------------------------------------------

master.dbo.xp_cmdshell ' osql -U username -P password -i c:\myquery.sql'

注意当前数据库要和.sql里要求的一致,或者在.sql里指明了数据库,否则达不到预期结果.

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus