[英]Is there any way to reference CDC objects in a SSDT database project?
I'm trying to create a database project from an extant database. 我正在尝试从现有数据库创建数据库项目。 Some of the tables in the database have CDC enabled. 数据库中的某些表已启用CDC。 For each such table, we've created a view into the CDC data that looks something like: 对于每个这样的表,我们都创建了一个CDC数据视图,如下所示:
create view [dbo].[vw_cdc_myTable] as
select
sys.fn_cdc_map_lsn_to_time (__$start_lsn) ActionLocalTime
, __$seqval ActionOrder
, __$operation ImageType
, case __$operation
when 1 then 'Deleted'
when 2 then 'Inserted'
when 3 then 'Before Update'
when 4 then 'After Update'
end ImageType_desc
, convert(char(5), '>>>>>') Sprtr
, *
from
cdc.dbo_myTable_CT
SSDT complains about this as it didn't import any of the CDC objects (in this case, cdc.dbo_myTable_CT and sys.fn_cdc_map_lsn_to_time). SSDT抱怨这一点,因为它没有导入任何CDC对象(在本例中为cdc.dbo_myTable_CT和sys.fn_cdc_map_lsn_to_time)。 Is there any way to either have those imported or to fake SSDT out so that I can have the view in source control? 有什么方法可以导入这些文件或伪造SSDT,以便可以将视图包含在源代码管理中?
Yes, there's a way to do it. 是的,有一种方法可以做到。 It's called cheating, but it works wonders. 这被称为作弊,但行之有效。
Follow these steps: 跟着这些步骤:
\n\n from [$(CDC)].cdc.dbo_myTable_CT 来自[$(CDC)]。cdc.dbo_myTable_CT\n\n
That's it! 而已!
You can also use this trick to make deployment ignore publishing of certain objects altogether while still husing them in some way. 您还可以使用此技巧使部署完全忽略某些对象的发布,同时仍以某种方式对其进行合并。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.