sql 同义词使用_使用同义词简化SQL Server代码

sql 同义词使用

问题 (Problem)

In our environment, we use different DB servers and these servers are linked via Linked servers for cross server transactions. We use these linked servers in our stored procedures. The server names are different in different environments and we had to change the server names manually when we promote the stored procedures to other environments. There is a chance of errors while changing the server names manually. In this article let us see how can we eliminate changing the code manually.

在我们的环境中,我们使用不同的数据库服务器,并且这些服务器通过链接服务器进行链接以进行跨服务器事务。 我们在存储过程中使用这些链接的服务器。 服务器名称在不同的环境中是不同的,当我们将存储过程升级到其他环境时,我们必须手动更改服务器名称。 手动更改服务器名称时可能会出错。 在本文中,让我们看看如何消除手动更改代码的麻烦。

(Solution)

We started doing POC on making our day to day SQL Server deployments/fixes automated by using tool like Source control, Compare and few other build and deployment tools.

我们开始通过使用诸如源代码控制,比较之类的工具以及其他一些构建和部署工具来使日常SQL Server部署/修复自动化来进行POC。

But before that, we want to make our database code uniform across environments. While comparing code in different environments, we found few procedures which are different. Some of them were actual code differences and some of them were different at linked servers only.

但是在此之前,我们希望使数据库代码在不同环境之间保持统一。 在不同环境中比较代码时,我们发现很少有不同的过程。 其中一些是实际的代码差异,而某些则仅在链接服务器上不同。

Our database code is tight coupled with inked servers. Linked servers are used to query the databases on different servers. These servers can be SQL Server or any other database engine.

我们的数据库代码与墨迹服务器紧密结合。 链接服务器用于查询不同服务器上的数据库。 这些服务器可以是SQL Server或任何其他数据库引擎。

To illustrate this, I am using sample server names. All the servers are SQL Servers and a linked server is created from server 1 to server 2 on all environments.

为了说明这一点,我使用了示例服务器名称。 所有服务器都是SQL Server,并且在所有环境中都创建了从服务器1到服务器2的链接服务器。

Development Servers:

开发服务器:

  • DEV1
  • DEV1
  • DEV2
  • DEV2

QA Servers:

质量检查服务器:

  • QA1
  • QA1
  • QA2
  • QA2

Production Servers:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值