如何将数据插入到一个数据库的视图中而不依赖于SQL Server中另一个数据库的表?

时间:2021-08-05 15:42:53

I have a View called View1 in DB1 and I have a table called Table1 in another database DB2. When I tried to insert data into View1, It's showing error like "Cannot insert the value NULL into column PrecisionQueueID, table DB1.Table1; Column doesn't allow nulls. INSERT fails"

我在DB1中有一个名为View1的View,我在另一个数据库DB2中有一个名为Table1的表。当我尝试将数据插入View1时,它显示的错误如“无法将值NULL插入列PrecisionQueueID,表DB1.Table1;列不允许空值.INSERT失败”

From this error I understood that Table1 having the PrecisionQueueID but View1 doesn't have PrecisionQueueID. So when I tried to insert data into View1 it's showing error.

从这个错误我明白Table1具有PrecisionQueueID但View1没有PrecisionQueueID。因此,当我尝试将数据插入View1时,它显示错误。

Table1 columns:

表1列:

DateTime
SkillTargetID
SkillGroupSkillTargetID
PrecisionQueueID
TimeZone

View1 Columns:

View1列:

DateTime
SkillTargetID
SkillGroupSkillTargetID
TimeZone

My Question is How to remove this link between Table1 and View1? I want to insert data into View1 without the dependency of that Table1 in SQL Server.

我的问题是如何删除Table1和View1之间的这个链接?我想将数据插入到View1中,而不依赖于SQL Server中的Table1。

如何将数据插入到一个数据库的视图中而不依赖于SQL Server中另一个数据库的表?

1 个解决方案

#1


0  

With the help of the AndyKorneyev's comment (Unable to get the comment link to cite) and Eralper's comment I got the solution.

在AndyKorneyev的评论(无法获得评论链接引用)和Eralper的评论的帮助下,我得到了解决方案。

As we can't insert data manually into the View, I just inserted the data into the table which is referring by the View. So I got the records as I expected.

由于我们无法手动将数据插入到View中,因此我只是将数据插入到View引用的表中。所以我得到了我预期的记录。

#1


0  

With the help of the AndyKorneyev's comment (Unable to get the comment link to cite) and Eralper's comment I got the solution.

在AndyKorneyev的评论(无法获得评论链接引用)和Eralper的评论的帮助下,我得到了解决方案。

As we can't insert data manually into the View, I just inserted the data into the table which is referring by the View. So I got the records as I expected.

由于我们无法手动将数据插入到View中,因此我只是将数据插入到View引用的表中。所以我得到了我预期的记录。