ssms只有空白解决方案

DBAs and developers manage a broad set of queries, codes, applications. It is a good practice to organize code or t-SQL scripts so that we can easily access them without wasting time searching for them. You might use Visual Studio, GitHub source control for it. In this article, we look at how Solutions and Projects help to organize T-SQL scripts.

DBA和开发人员管理着广泛的查询,代码和应用程​​序。 组织代码或t-SQL脚本是一种好习惯,这样我们就可以轻松访问它们而不会浪费时间搜索它们。 您可以使用Visual Studio,GitHub源代码控件。 在本文中,我们研究解决方案和项目如何帮助组织T-SQL脚本。

I am using the latest general availability release SSMS 18.4. You can download it from Microsoft docs.

我正在使用最新的一般可用性版本SSMS 18.4。 您可以从Microsoft文档下载它。

SQL Server Management Studio项目 (SQL Server Management Studio Projects)

We can organize T-SQL codes using SSMS projects. Go to New-> Project.

我们可以使用SSMS项目来组织T-SQL代码。 转到新建->项目。

It opens a new project configuration window. Here, we do the following configurations.

它打开一个新的项目配置窗口。 在这里,我们进行以下配置。

  1. SQL Server Scripts or SQL Server脚本”或“ Analysis Services Script. Let’s select SQL Server Scripts for this article Analysis Services脚本” 。 让我们为本文选择SQL Server脚本
  2. Specify a project name 指定项目名称
  3. Specify a directory to save this project 指定目录以保存该项目

Click OK, and it opens the Solution Explorer to manage the project and its resources.

单击“确定”,它将打开解决方案资源管理器来管理项目及其资源。

If this solution explorer is not visible, go to View-> Solution Explorer. You can also use keyboard shortcut Ctrl+Alt+L.

如果此解决方案资源管理器不可见,请转到“ 视图”->“解决方案资源管理器”。 您也可以使用键盘快捷键Ctrl + Alt + L。

The solution is a logical grouping of project-related resources. By default, SQL Server creates a solution for every project with a similar name. We can create multiple projects in a solution. Let’s create a new project in the same solution.

解决方案是对与项目相关的资源进行逻辑分组。 默认情况下,SQL Server为具有相似名称的每个项目创建一个解决方案。 我们可以在一个解决方案中创建多个项目。 让我们在相同的解决方案中创建一个新项目。

Go to File -> New -> Project. It opens the same new project window. Here, Select Add to Solution to add the project into exiting solution.

转到文件->新建->项目。 它将打开相同的新项目窗口。 在这里,选择添加到解决方案以将项目添加到现有解决方案中。

Click OK, and it adds a new project into the existing project, as shown below. Here, we see each project contains different objects: Connections, Queries, and Miscellaneous.

单击确定,它将新项目添加到现有项目中,如下所示。 在这里,我们看到每个项目都包含不同的对象:连接,查询和其他。

连接数 (Connections)

In the connection tab, we can create multiple SQL Server connections for different environments, servers. Suppose you have a Dev, Test, and Production environment, and we can run queries on any environment based on our requirement.

在连接选项卡中,我们可以为不同环境的服务器创建多个SQL Server连接。 假设您具有开发,测试和生产环境,并且我们可以根据需要在任何环境上运行查询。

Right-click on Connections and New Connection.

右键单击“连接和新建连接”。

It opens the SSMS SQL Server connection window. Specify SQL Instance, Authentication (Windows or SQL ), and connect to the instance.

它会打开SSMS SQL Server连接窗口。 指定SQL实例,身份验证(Windows或SQL),然后连接到该实例。

It shows the instance in the connection window.

它在连接窗口中显示实例。

查询 (Queries)

In the query tab, we can create multiple SQL query files. You can either click on a connection to open a new query window.

在查询选项卡中,我们可以创建多个SQL查询文件。 您可以单击连接以打开新的查询窗口。

Let’s specify a system stored procedure SP_HELPDB in the new query window. Click on Execute or press F5 to execute the query.

让我们在新的查询窗口中指定系统存储过程SP_HELPDB 。 单击执行或按F5执行查询。

Right-click on the query title and save it.

右键单击查询标题并保存。

Once you save the query, it shows a green color in front of the query text.

保存查询后,查询文本前会显示绿色。

Right-click on the query file and rename it. You should give it a familiar name so that you can easily identify queries from the file name. It is advantageous if you have a large number of query files.

右键单击查询文件,然后重命名。 您应该给它起一个熟悉的名称,以便您可以轻松地从文件名中识别查询。 如果您有大量查询文件,这将是非常有利的。

Here, we name the file as sp_helpdb.sql

在这里,我们将文件命名为sp_helpdb.sql

Similarly, create another SQL file and save it, as shown below. You can store many files in the solution.

同样,创建另一个SQL文件并保存,如下所示。 您可以在解决方案中存储许多文件。

Let’s close the SSMS and open it again. To open existing projects, click on File – Open -> Project/Solution.

让我们关闭SSMS,然后再次打开它。 要打开现有项目,请单击文件–打开->项目/解决方案。

It takes you the default directory for the projects.

它为您提供了项目的默认目录。

Select the specific project (in this case – SQLShack) and Open it. Here, it shows a separate folder for each project in SSMS, as shown in the following image. It also has a solution file (extension .ssmsln). Select this solution file and open it.

选择特定项目(在本例中为SQLShack)并打开它。 在这里,它为SSMS中的每个项目显示了一个单独的文件夹,如下图所示。 它还有一个解决方案文件(扩展名.ssmsln )。 选择此解决方案文件并打开它。

It opens the solution explorer with existing connections, SQL files, and miscellaneous files. You can double-click on existing files and start working on these.

它将使用现有连接,SQL文件和其他文件打开解决方案资源管理器。 您可以双击现有文件并开始处理这些文件。

杂项文件 (Miscellaneous Files)

If we have any external files for the project, it appears in the Miscellaneous files section. You might not be aware that, using SSMS, we can create, modify a lot of files other than SQL query files. Click on File-> New -> File and it gives a list of files such as Text, HTML page, JavaScript, XML. Icon, Cursor, VbClass files.

如果我们有项目的任何外部文件,它将显示在“其他文件”部分中。 您可能不知道,使用SSMS,我们可以创建,修改SQL查询文件以外的许多文件。 单击文件->新建->文件 ,它会提供文件列表,例如文本,HTML页面,JavaScript,XML。 图标,光标,VbClass文件。

Let’s click on an HTML file, and you can see it under the Miscellaneous files as shown below.

让我们单击一个HTML文件,您可以在“杂项”文件下看到它,如下所示。

将文件从项目复制到解决方案中的另一个项目 (Copy files from a project to another in a solution)

As I already stated, we can create multiple projects in a single project. We created two projects [Demo Project] and [SQLShack] in the current solution. Suppose we created these projects for the test and production environment.

如前所述,我们可以在一个项目中创建多个项目。 在当前解决方案中,我们创建了两个项目[Demo Project]和[SQLShack]。 假设我们为测试和生产环境创建了这些项目。

Initially, we added the SQL file and miscellaneous files in the test project (Demo Project). Once we completed development work for specific files, we want to move them into the production project (SQLShack). We can easily copy the files between the projects in a solution.

最初,我们在测试项目(Demo Project)中添加了SQL文件和其他文件。 完成针对特定文件的开发工作后,我们希望将其移至生产项目(SQLShack)。 我们可以轻松地在解决方案中的项目之间复制文件。

Right-click on the destination project and go to Existing item.

右键单击目标项目,然后转到“现有项目”。

It opens the solution folder, and you see both projects created in the solution.

它打开解决方案文件夹,您会看到在解决方案中创建的两个项目。

Open the source project (in this case, Demo Project) and select the SQL file you wish to copy in the SQLShack project. Here, we wish to copy the sp_helpdb.sql file in the SQLShack project.

打开源项目(在本例中为演示项目),然后选择要复制到SQLShack项目中SQL文件。 在这里,我们希望将sp_helpdb.sql文件复制到SQLShack项目中。

Click on Add, and you can see the file in the SQLShack project as well. In this case, sp_helpdb.sql file in both projects is independent of each other. If you modify a file in one project, it does not change the second project file.

单击添加,您也可以在SQLShack项目中看到该文件。 在这种情况下,两个项目中的sp_helpdb.sql文件彼此独立。 如果您在一个项目中修改文件,则不会更改第二个项目文件。

添加链接选项以引用其他项目中的文件 (Add a link option to reference files from other projects)

Sometimes, we want to reference another project file. If someone does any changes in the existing file, changes should be visible in another project as well. For this, we can click on Add as Link, as shown below.

有时,我们想引用另一个项目文件。 如果有人在现有文件中进行任何更改,则更改也应该在另一个项目中可见。 为此,我们可以单击“ 添加为链接”,如下所示。

Let’s add sp_who2.sql file using option Add as Link.

让我们使用选项“ 添加为链接”添加sp_who2.sql文件

Now, open the sp_who2.sql file for the Demo project and change it as follows.

现在,打开Demo项目的sp_who2.sql文件,并如下进行更改。

Save the changes and close the .sql file. Now, open the sp_who2.sql file from the SQLShack project. We added this file as a link from the [Demo Project]. As shown in the following screenshot, changes are visible in this project as well.

保存更改并关闭.sql文件。 现在,从SQLShack项目中打开sp_who2.sql文件。 我们将此文件添加为[Demo Project]中的链接。 如以下屏幕截图所示,更改在此项目中也可见。

在SSMS中更改项目和解决方案的默认视图 (Change the default view of Projects and Solutions in SSMS)

By default, it shows the solution and project in visual studio style.

默认情况下,它以Visual Studio样式显示解决方案和项目。

Click on the highlighted folder icon, and it changes the look, as shown below. In this view, we can see the solution directory, solution file, and project files. It does not group files in a different folder in a project.

单击突出显示的文件夹图标,它将改变外观,如下所示。 在此视图中,我们可以看到解决方案目录,解决方案文件和项目文件。 它不会将文件分组到项目中其他文件夹中。

You can click on a solution file to view the XML content of the file.

您可以单击解决方案文件以查看文件的XML内容。

结论 (Conclusion)

In this article, we explored Projects and Solutions in SSMS to organize different projects, files, and connections. We can also manage miscellaneous files such as text, HTML, XML using this feature.

在本文中,我们探索了SSMS中的“项目和解决方案”来组织不同的项目,文件和连接。 我们还可以使用此功能管理其他文件,例如文本,HTML,XML。

翻译自: https://www.sqlshack.com/overview-of-solutions-and-projects-in-ssms/

ssms只有空白解决方案

ssms只有空白解决方案_SSMS中的解决方案和项目概述相关推荐

  1. pads铺铜不能开启drp_PADS中常见问题解决方案

    PADS中常见问题解决方案 1.走线很细,不是设定值. 解答:有时将预拉线布好线后,所布的线变成了一根很细的线而不是我们所设定的线宽,但是查看它的属性也还是一样的,最小线宽显示值的设定大于route线 ...

  2. visual studio2019创建解决方案,并在一个解决方案中包含多个项目

    系列文章目录 文章目录 系列文章目录 前言 一.使用步骤 前言 之前一直使用visual studio2019一直都是一个解决方案,下面包含一个工程.这次写一个网络同步的模块,具体使用boost的as ...

  3. VS2005中建立解决方案及多项目

    下面我们建立一个名为ShopStore的项目,采用三层构架: 1.新建立一个空白解决方案文件,如下图: 2.此时解决方案中没有任何项目. 3.右键选择解决方案--选择添加新项目--选择类库(新建Dat ...

  4. 没有头文件调用cpp_VS2017中同一个解决方案下不同工程的调用

    解决方案结构如下图所示:解决方案project1下有三个工程:project1(我会用它调用其余两个).project2(其头文件含一个.h 一个.cpp).project3(其头文件含两个.h 两个 ...

  5. VS2008中的“解决方案配置”和“解决方案平台”不见了(Release和Debug)的解决方法...

    VS2008中的"解决方案配置"和"解决方案平台"不见了(Release和Debug)的解决方法 1.视图->工具栏->自定义 中->命令,选 ...

  6. 输入防抖 vue # 输入搜索的时候 及时搜索的快速访问接口的 解决方案 vue 中使用防抖和节流

    输入防抖 vue # 输入搜索的时候 及时搜索的快速访问接口的 解决方案 vue 中使用防抖和节流 参考文章: (1)输入防抖 vue # 输入搜索的时候 及时搜索的快速访问接口的 解决方案 vue ...

  7. Visual Studio中没有为此解决方案配置选中要生成的项目

    Visual Studio中没有为此解决方案配置选中要生成的项目 参考文章: (1)Visual Studio中没有为此解决方案配置选中要生成的项目 (2)https://www.cnblogs.co ...

  8. 超优 Vue+Element+Spring 中后端解决方案

    今日推荐 推荐一款开源 Java 版的视频管理系统 推荐3个快速开发平台 前后端都有 项目经验又有着落了 14个项目 转载:toutiao.com/i6911704074815767048 作者:we ...

  9. TCP的粘包和拆包及Netty中的解决方案

    1.基本介绍 TCP 是面向连接的,面向流的,提供高可靠性服务.收发两端(客户端和服务器端)都要有一一成对的 socket, 因此,发送端为了将多个发给接收端的包,更有效的发给对方,使用了优化方法(N ...

最新文章

  1. Ubuntu安装Flash视频插件
  2. Containerpilot 配置文件reload
  3. 《漫画算法2》源码整理-7 第K大的数字
  4. 禁用cookie后怎么使用session_Session 和 Cookie 的区别?你在项目中哪些地方使用了?...
  5. 我给非洲医药基金会捐的款和感谢信
  6. Python - python不是内部或外部命令
  7. SSM三大框架超详细总结(适合你重新回顾)
  8. 计算机三维技术在影视广告设计中应用的研究 罗晋,计算机三维技术在影视广告设计中应用的研究...
  9. php -- php数组相关函数
  10. 【转】UINavigationController 直接返回到第一级目录
  11. ecshop商品列表页增加/显示货号SN
  12. git的丰富实用经验
  13. matlab实现S域到Z域变换
  14. 感冒、咳嗽、发烧、腹泻、扁桃体炎是儿童常见病
  15. MPB:南农韦中组-​根系分泌物调控土壤微生物群落结构和功能的研究方法
  16. DC-DC电源市场现状及未来发展趋势分析
  17. 字符串的方法练习------Python篇
  18. 反病毒利器Autoruns和ProcessExplorer, SREng - 本人推荐使用的查毒杀毒辅助工具
  19. el-table合计
  20. 【THUWC2017】在美妙的数学王国中畅游

热门文章

  1. vs没有添加引用_NBA 季后赛 湖人vs火箭 G2大战谁能防住哈登?
  2. 一文带你了解Java反射机制
  3. 设计模式之 --- 工厂模式(下)
  4. hdu---1172猜数字
  5. 暑假第二周总结(2018.7.16——7.22)
  6. Access 中数据库操作时提示from子句语法错误
  7. DataSet.GetBookMark内存泄漏
  8. 数组02 - 零基础入门学习C语言24
  9. 我喜欢的歌-FOREVER
  10. 模拟新浪新闻在线聊天功能