存储过程中如何直接执行.SQL文件?

请问:
在存储过程中,能否执行外部的文件?
比如:将数据库结构导成sql文件,在存储过程中调用执行?
---------------------------------------------------------------

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

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

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