在视图中交换两列 [英] Swap two columns in view

查看:143
本文介绍了在视图中交换两列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试在视图中交换两列的值。

I'm trying to swap values of two columns in view.

  UPDATE data $ SET [floor 1] = [floor 2],[floor 2] = [floor 1]

 UPDATE data$ SET [floor 1]=[floor 2] , [floor 2]=[floor 1]

我在新创建的表中尝试了这段代码并且它有效。

I've tried this code in newly created table and it worked.

当我尝试在另一个数据库的表中使用此代码时,我得到的错误是没有派生或常量字段。我有权改变桌子。可能是这个错误的来源是什么?

When I try to use this code in table from another database, I get error that there is no derived or constant field. i have rights to alter table. What can be source of this error?

问候,

Yerkhan

推荐答案

这是一个视图吗?

Is this a view?

https://docs.microsoft.com/en-us/sql/t-sql/statements/create-view-transact -sql?view = sql-server-2017

https://docs.microsoft.com/en-us/sql/t-sql/statements/create-view-transact-sql?view=sql-server-2017

/ *此更新无效,因为您的视图未满足这些条件/限制。* /

/*The update is not working because your view don't fullfil these conditions/restrictions.*/

您似乎已经编写了一个INSTEAD OF触发器来实现更新。

Looks like you have to write an INSTEAD OF trigger to implement your update.


这篇关于在视图中交换两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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