在SQL Server中导入现有存储过程 [英] Import Existing Stored Procedures In SQL Server

查看:366
本文介绍了在SQL Server中导入现有存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从生产中恢复了我的开发数据库,​​而我的开发环境中所需的存储过程在我的生产数据库中不存在。是否可以使用命令将developmetn存储过程导入SQL Server。大约有88个文件,因为每个程序都在不同的文本文件中。

I restored my development database from production, and the stored procedures I need in my development environment doesn't exist in my production database. Is there a command Ii can use to import the developmetn stored procedures back into SQL Server. There are about 88 files, as each procedure is in a different text file.

TIA!
Chris

TIA! Chris

推荐答案

哎呀,你做了生成脚本的痛苦方法。您应该通过右键单击SSMS中的数据库,选择任务 - >生成脚本,为所有过程创建一个脚本。

Oops, you did the painful way of generating scripts. You should have created a single script for all procedures by right clicking on the database in SSMS, choosing Tasks -> Generate Scripts.

但是,如果您不想再次完成该过程,打开文件夹中的cmd shell并记住那些旧的批处理文件天:

However, if you don't want to go through that process again, open up a cmd shell in the folder and remember those old batch file days:

for %f in (*.sql) do sqlcmd -i %f

这应该可行!
如果需要,您可以将其他参数添加到sqlcmd(即登录名,密码,服务器名称......)。要查看交换机列表,只需执行 sqlcmd -h

这篇关于在SQL Server中导入现有存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆