如何使用 SQL Server Management Studio 运行 sql 脚本? [英] How to run sql script using SQL Server Management Studio?

查看:196
本文介绍了如何使用 SQL Server Management Studio 运行 sql 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在关注本教程:http://www.misfitgeek.com/2010/07/adding-asp-net-membership-to-your-own-database/

我从这里安装了 SQL Server Management Studio Express:http://www.microsoft.com/download/en/details.aspx?id=8961.

I have installed SQL Server Management Studio Express from here: http://www.microsoft.com/download/en/details.aspx?id=8961.

1) 如何定位我的数据库?

1) How can I locate my database?

2) 如何从外部文件在我的数据库上运行 SQL 脚本?

2) How do I run the SQL script on my database from external file?

推荐答案

本网站 有一个简明的教程,介绍如何使用 SQL Server Management Studio.正如您将看到的,您可以打开一个查询窗口",粘贴您的脚本并运行它.它不允许您使用文件路径执行脚本.但是,您可以使用命令行 (cmd.exe) 轻松完成此操作:

This website has a concise tutorial on how to use SQL Server Management Studio. As you will see you can open a "Query Window", paste your script and run it. It does not allow you to execute scripts by using the file path. However, you can do this easily by using the command line (cmd.exe):

sqlcmd -S .\SQLExpress -i SqlScript.sql

其中 SqlScript.sql 是位于当前目录的脚本文件名.有关更多示例,请参阅此 Microsoft 页面

Where SqlScript.sql is the script file name located at the current directory. See this Microsoft page for more examples

这篇关于如何使用 SQL Server Management Studio 运行 sql 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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