{"id":2515,"date":"2014-07-23T08:50:29","date_gmt":"2014-07-23T07:50:29","guid":{"rendered":"http:\/\/help.sdna.lu\/?p=2515&#038;lang=en"},"modified":"2021-04-28T20:35:31","modified_gmt":"2021-04-28T19:35:31","slug":"query-useful-versionlink-queries","status":"publish","type":"post","link":"https:\/\/sdna.lu\/?p=2515","title":{"rendered":"Query: VersionLink Queries"},"content":{"rendered":"<p><code>1) Select Environment, count(*) from VersionLink Group by Environment<\/code><\/p>\n<p><code>2) Select Environment, count(*) from VersionLink where not Environment =&nbsp;'Your Environment' Group by Environment<\/code><\/p>\n<p><code>3) Select * from VersionLink where not Environment = '@Environment@'<\/code><\/p>\n<p><code>4) Delete from VersionLink where not Environment = '@Environment@'<\/code><\/p>\n<p><code>5) Select TableName, count(*) from VersionLink Group by TableName order by TableName<\/code><\/p>\n<p><code>6) Select * from VersionLink where TableName = '@TableName@'<\/code><\/p>\n<p><code>7) Delete from [VersionLink] where TableName = '@TableName@'<\/code><\/p>\n<p><code>8) Select * from [Licence].[DeMaSy].[DBList] as [ResultDBList] where Not [DBId] in (Select DBId from [DeMaSy].[DeMaSy].[VersionLink] where [TableName] = '@TableName@') order by [ResultDBList].[LogicalName]<\/code><\/p>\n<p><code>9) Select distinct [DBId] from [Licence].[DeMaSy].[DBList] as [ResultDBList] where Not [DBId] in<br>\n(Select [DBId] from [DeMaSy].[DeMaSy].[VersionLink] where [TableName] = '@TableName@') and Not [DBId] in (0)<\/code><\/p>\n<p><code>10) <span lang=\"EN-US\">Insert Into [VersionLink] ([DBId], [Environment], [TableName], [PhysicalLocation], [DestDBId], [DBType]) Select [DBId], '@Environment@', '@Table@', '@PhysicalLocation@', 0, @DBType@ from [Licence].[DeMaSy].[DBList] as [ResultDBList] where Not [DBId] in (Select DBId from [DeMaSy].[DeMaSy].[VersionLink] where TableName = '@TableName@') and not [DBId] = 0<\/span><\/code><\/p>\n<p><code>11) <span lang=\"EN-US\">Select * from [@TableName@] where [DBId] in (Select [DBId] from [Licence].[DeMaSy].[DBList] as [ResultDBList] where Not [DBId] in (Select [DBId] from [DeMaSy].[DeMaSy].[VersionLink] where TableName = '@TableName@'))<\/span><\/code><\/p>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1) Select Environment, count(*) from VersionLink Group by Environment 2) Select Environment, count(*) from VersionLink where not Environment =&nbsp;&#8216;Your Environment&#8217; Group by Environment 3) Select * from VersionLink where not Environment = &#8216;@Environment@&#8217; 4) Delete from VersionLink where not Environment = &#8216;@Environment@&#8217; 5) Select TableName, count(*) from VersionLink Group by TableName order by TableName 6) [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[487],"tags":[153,154],"class_list":["post-2515","post","type-post","status-publish","format-standard","hentry","category-query","tag-query","tag-versionlink"],"_links":{"self":[{"href":"https:\/\/sdna.lu\/index.php?rest_route=\/wp\/v2\/posts\/2515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdna.lu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdna.lu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdna.lu\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sdna.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2515"}],"version-history":[{"count":13,"href":"https:\/\/sdna.lu\/index.php?rest_route=\/wp\/v2\/posts\/2515\/revisions"}],"predecessor-version":[{"id":11506,"href":"https:\/\/sdna.lu\/index.php?rest_route=\/wp\/v2\/posts\/2515\/revisions\/11506"}],"wp:attachment":[{"href":"https:\/\/sdna.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdna.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdna.lu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}