<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Evgeniy Gribkov</title>
    <description>The latest articles on DEV Community by Evgeniy Gribkov (@jobgemws).</description>
    <link>https://dev.to/jobgemws</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F341015%2Fc657bfdb-3dc4-4e23-af97-1a4ea2e32f5c.jpeg</url>
      <title>DEV Community: Evgeniy Gribkov</title>
      <link>https://dev.to/jobgemws</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jobgemws"/>
    <language>en</language>
    <item>
      <title>How to see a history of queries ran on a SQL server</title>
      <dc:creator>Evgeniy Gribkov</dc:creator>
      <pubDate>Fri, 02 Oct 2020 06:47:05 +0000</pubDate>
      <link>https://dev.to/jobgemws/how-to-see-a-history-of-queries-ran-on-a-sql-server-3fko</link>
      <guid>https://dev.to/jobgemws/how-to-see-a-history-of-queries-ran-on-a-sql-server-3fko</guid>
      <description>&lt;p&gt;You can review query history in one of the following ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Queries are saved in the cache via system representations like sys.dm_exec_query_stats, sys.dm_exec_sql_text и sys.dm_exec_query_plan
For example, you can output 100 queries with the highest execution time (including all delays) using the following script:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;with s as (&lt;br&gt;
select top(100)&lt;br&gt;
creation_time,&lt;br&gt;
last_execution_time,&lt;br&gt;
execution_count,&lt;br&gt;
total_worker_time/1000 as CPU,&lt;br&gt;
convert(money, (total_worker_time))/(execution_count*1000)as [AvgCPUTime],&lt;br&gt;
qs.total_elapsed_time/1000 as TotDuration,&lt;br&gt;
convert(money, (qs.total_elapsed_time))/(execution_count*1000)as [AvgDur],&lt;br&gt;
total_logical_reads as [Reads],&lt;br&gt;
total_logical_writes as [Writes],&lt;br&gt;
total_logical_reads+total_logical_writes as [AggIO],&lt;br&gt;
convert(money, (total_logical_reads+total_logical_writes)/(execution_count + 0.0)) as [AvgIO],&lt;br&gt;
[sql_handle],&lt;br&gt;
plan_handle,&lt;br&gt;
statement_start_offset,&lt;br&gt;
statement_end_offset,&lt;br&gt;
plan_generation_num,&lt;br&gt;
total_physical_reads,&lt;br&gt;
convert(money, total_physical_reads/(execution_count + 0.0)) as [AvgIOPhysicalReads],&lt;br&gt;
convert(money, total_logical_reads/(execution_count + 0.0)) as [AvgIOLogicalReads],&lt;br&gt;
convert(money, total_logical_writes/(execution_count + 0.0)) as [AvgIOLogicalWrites],&lt;br&gt;
query_hash,&lt;br&gt;
query_plan_hash,&lt;br&gt;
total_rows,&lt;br&gt;
convert(money, total_rows/(execution_count + 0.0)) as [AvgRows],&lt;br&gt;
total_dop,&lt;br&gt;
convert(money, total_dop/(execution_count + 0.0)) as [AvgDop],&lt;br&gt;
total_grant_kb,&lt;br&gt;
convert(money, total_grant_kb/(execution_count + 0.0)) as [AvgGrantKb],&lt;br&gt;
total_used_grant_kb,&lt;br&gt;
convert(money, total_used_grant_kb/(execution_count + 0.0)) as [AvgUsedGrantKb],&lt;br&gt;
total_ideal_grant_kb,&lt;br&gt;
convert(money, total_ideal_grant_kb/(execution_count + 0.0)) as [AvgIdealGrantKb],&lt;br&gt;
total_reserved_threads,&lt;br&gt;
convert(money, total_reserved_threads/(execution_count + 0.0)) as [AvgReservedThreads],&lt;br&gt;
total_used_threads,&lt;br&gt;
convert(money, total_used_threads/(execution_count + 0.0)) as [AvgUsedThreads]&lt;br&gt;
from sys.dm_exec_query_stats as qs with(readuncommitted)&lt;br&gt;
order by convert(money, (qs.total_elapsed_time))/(execution_count*1000) desc&lt;br&gt;
)&lt;br&gt;
select&lt;br&gt;
s.creation_time,&lt;br&gt;
s.last_execution_time,&lt;br&gt;
s.execution_count,&lt;br&gt;
s.CPU,&lt;br&gt;
s.[AvgCPUTime],&lt;br&gt;
s.TotDuration,&lt;br&gt;
s.[AvgDur],&lt;br&gt;
s.[AvgIOLogicalReads],&lt;br&gt;
s.[AvgIOLogicalWrites],&lt;br&gt;
s.[AggIO],&lt;br&gt;
s.[AvgIO],&lt;br&gt;
s.[AvgIOPhysicalReads],&lt;br&gt;
s.plan_generation_num,&lt;br&gt;
s.[AvgRows],&lt;br&gt;
s.[AvgDop],&lt;br&gt;
s.[AvgGrantKb],&lt;br&gt;
s.[AvgUsedGrantKb],&lt;br&gt;
s.[AvgIdealGrantKb],&lt;br&gt;
s.[AvgReservedThreads],&lt;br&gt;
s.[AvgUsedThreads],&lt;br&gt;
--st.text as query_text,&lt;br&gt;
case&lt;br&gt;
when sql_handle IS NULL then ' '&lt;br&gt;
else(substring(st.text,(s.statement_start_offset+2)/2,(&lt;br&gt;
case&lt;br&gt;
when s.statement_end_offset =-1 then len(convert(nvarchar(MAX),st.text))*2      &lt;br&gt;
else s.statement_end_offset    &lt;br&gt;
end - s.statement_start_offset)/2  ))&lt;br&gt;
end as query_text,&lt;br&gt;
db_name(st.dbid) as database_name,&lt;br&gt;
object_schema_name(st.objectid, st.dbid)+'.'+object_name(st.objectid, st.dbid) as [object_name],&lt;br&gt;
sp.[query_plan],&lt;br&gt;
s.[sql_handle],&lt;br&gt;
s.plan_handle,&lt;br&gt;
s.query_hash,&lt;br&gt;
s.query_plan_hash&lt;br&gt;
from s&lt;br&gt;
cross apply sys.dm_exec_sql_text(s.[sql_handle]) as st&lt;br&gt;
cross apply sys.dm_exec_query_plan(s.[plan_handle]) as sp&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using SQL &lt;a href="https://docs.microsoft.com/en-us/sql/tools/sql-server-profiler/sql-server-profiler?view=sql-server-ver15" rel="noopener noreferrer"&gt;Server Profiler&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Using &lt;a href="https://docs.microsoft.com/en-us/sql/relational-databases/extended-events/extended-events?view=sql-server-ver15" rel="noopener noreferrer"&gt;Extended Events&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Using &lt;a href="https://docs.microsoft.com/en-us/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store?view=sql-server-ver15" rel="noopener noreferrer"&gt;Query Store&lt;/a&gt;, starting from the 2016 version.&lt;/li&gt;
&lt;li&gt;Using third-party tools like &lt;a href="https://dbeaver.io/" rel="noopener noreferrer"&gt;DBeaver&lt;/a&gt; (Database\Transaction Log):&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdmoboaw7d%2Fimage%2Fupload%2Fv1601460363%2Ffig1_vat1ds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdmoboaw7d%2Fimage%2Fupload%2Fv1601460363%2Ffig1_vat1ds.png" title="Fig.1 Transaction Log in DBeaver" alt="Fig.1 Transaction Log in DBeaver"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using &lt;a href="https://www.devart.com/dbforge/sql/sqlcomplete/" rel="noopener noreferrer"&gt;SQL Complete&lt;/a&gt; (SQL Complete\Execution History) in &lt;a href="https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15" rel="noopener noreferrer"&gt;SSMS&lt;/a&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdmoboaw7d%2Fimage%2Fupload%2Fv1601460363%2Ffig2_wsitrt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdmoboaw7d%2Fimage%2Fupload%2Fv1601460363%2Ffig2_wsitrt.png" title="Fig.2 Execution History in SQL Complete" alt="Fig.2 Execution History in SQL Complete"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>sql</category>
      <category>sqlserver</category>
    </item>
    <item>
      <title>Set up Extended Events in SQL Server</title>
      <dc:creator>Evgeniy Gribkov</dc:creator>
      <pubDate>Thu, 01 Oct 2020 11:03:12 +0000</pubDate>
      <link>https://dev.to/jobgemws/set-up-extended-events-in-sql-server-3a9k</link>
      <guid>https://dev.to/jobgemws/set-up-extended-events-in-sql-server-3a9k</guid>
      <description>&lt;p&gt;Extended events are used to monitor the DBMS’s state.&lt;br&gt;
There is a standard preconfigured session called system_health, and the most important criteria are gathered in it:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Af3zot2B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Af3zot2B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig1.png" alt="Fig.1 system_health session" title="Fig.1 system_health session" width="273" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Despite deadlocks being collected in the system_health session, it’s often handy to create a separate session for this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C4sosa3L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C4sosa3L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig2.png" alt="Fig.2 The Deadlocks session" title="Fig.2 The Deadlocks session" width="800" height="589"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BgvLzNio--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BgvLzNio--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig3.png" alt="Fig.3 Events in the Deadlocks session" title="Fig.3 Events in the Deadlocks session" width="800" height="589"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code for Deadlocks session creation will be similar to this:&lt;br&gt;
&lt;code&gt;CREATE EVENT SESSION [Deadlocks] ON SERVER&lt;br&gt;
ADD EVENT sqlserver.xml_deadlock_report&lt;br&gt;
ADD TARGET package0.event_file(SET filename=N'Deadlocks')&lt;br&gt;
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON)&lt;br&gt;
GO&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Extended events can also be created by a popular monitor called &lt;a href="https://www.quest.com/products/spotlight-on-sql-server-enterprise/"&gt;Spotlight&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f5ZA9Ky1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f5ZA9Ky1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig4.png" alt="Fig.4 Extended events in Spotlight" title="Fig.4 Extended events in Spotlight" width="800" height="589"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code for Spotlight session creation will be similar to this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CREATE EVENT SESSION [SpotlightMonitoring_com_sqlserver] ON SERVER&lt;br&gt;
ADD EVENT sqlos.wait_info(&lt;br&gt;
    ACTION(package0.collect_system_time,sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_name,sqlserver.is_system,sqlserver.plan_handle,sqlserver.session_id,sqlserver.tsql_frame,sqlserver.username)&lt;br&gt;
    WHERE ([sqlserver].[is_system]=(0) AND [opcode]=(1) AND ([duration]&amp;gt;(0) OR [signal_duration]&amp;gt;(0)) AND [wait_type]&amp;lt;&amp;gt;(755) AND [wait_type]&amp;lt;&amp;gt;(177) AND [wait_type]&amp;lt;&amp;gt;(413) AND [wait_type]&amp;lt;&amp;gt;(285) AND [wait_type]&amp;lt;&amp;gt;(359) AND [wait_type]&amp;lt;&amp;gt;(137) AND [wait_type]&amp;lt;&amp;gt;(132) AND [wait_type]&amp;lt;&amp;gt;(232) AND [wait_type]&amp;lt;&amp;gt;(231) AND [wait_type]&amp;lt;&amp;gt;(230) AND [wait_type]&amp;lt;&amp;gt;(356) AND [wait_type]&amp;lt;&amp;gt;(141) AND [wait_type]&amp;lt;&amp;gt;(140) AND [wait_type]&amp;lt;&amp;gt;(143) AND [wait_type]&amp;lt;&amp;gt;(144) AND [wait_type]&amp;lt;&amp;gt;(121) AND [wait_type]&amp;lt;&amp;gt;(813) AND [wait_type]&amp;lt;&amp;gt;(393) AND [wait_type]&amp;lt;&amp;gt;(296) AND [wait_type]&amp;lt;&amp;gt;(801) AND [wait_type]&amp;lt;&amp;gt;(839) AND [wait_type]&amp;lt;&amp;gt;(382) AND [wait_type]&amp;lt;&amp;gt;(151) AND [wait_type]&amp;lt;&amp;gt;(651) AND [wait_type]&amp;lt;&amp;gt;(767) AND [wait_type]&amp;lt;&amp;gt;(661) AND [wait_type]&amp;lt;&amp;gt;(855) AND [wait_type]&amp;lt;&amp;gt;(775) AND [wait_type]&amp;lt;&amp;gt;(857) AND [wait_type]&amp;lt;&amp;gt;(856) AND [wait_type]&amp;lt;&amp;gt;(884) AND [wait_type]&amp;lt;&amp;gt;(871) AND [wait_type]&amp;lt;&amp;gt;(854) AND [wait_type]&amp;lt;&amp;gt;(859) AND [wait_type]&amp;lt;&amp;gt;(858) AND [wait_type]&amp;lt;&amp;gt;(853) AND [wait_type]&amp;lt;&amp;gt;(873) AND [wait_type]&amp;lt;&amp;gt;(881) AND [wait_type]&amp;lt;&amp;gt;(782) AND [wait_type]&amp;lt;&amp;gt;(780) AND [wait_type]&amp;lt;&amp;gt;(841) AND [wait_type]&amp;lt;&amp;gt;(798) AND [wait_type]&amp;lt;&amp;gt;(799) AND [wait_type]&amp;lt;&amp;gt;(130) AND [wait_type]&amp;lt;&amp;gt;(786) AND [wait_type]&amp;lt;&amp;gt;(96) AND [wait_type]&amp;lt;&amp;gt;(816) AND [wait_type]&amp;lt;&amp;gt;(605) AND [wait_type]&amp;lt;&amp;gt;(1021) AND [wait_type]&amp;lt;&amp;gt;(991) AND [wait_type]&amp;lt;&amp;gt;(993) AND [wait_type]&amp;lt;&amp;gt;(883) AND [wait_type]&amp;lt;&amp;gt;(131) AND [wait_type]&amp;lt;&amp;gt;(283) AND [wait_type]&amp;lt;&amp;gt;(335) AND [wait_type]&amp;lt;&amp;gt;(347) AND [wait_type]&amp;lt;&amp;gt;(273) AND [wait_type]&amp;lt;&amp;gt;(100) AND [wait_type]&amp;lt;&amp;gt;(102) AND [wait_type]&amp;lt;&amp;gt;(107) AND [wait_type]&amp;lt;&amp;gt;(105) AND [wait_type]&amp;lt;&amp;gt;(109) AND [wait_type]&amp;lt;&amp;gt;(108) AND [wait_type]&amp;lt;&amp;gt;(754) AND [wait_type]&amp;lt;&amp;gt;(165) AND [wait_type]&amp;lt;&amp;gt;(348) AND [wait_type]&amp;lt;&amp;gt;(756) AND [wait_type]&amp;lt;&amp;gt;(392) AND [wait_type]&amp;lt;&amp;gt;(221) AND [wait_type]&amp;lt;&amp;gt;(800) AND [wait_type]&amp;lt;&amp;gt;(897) AND [wait_type]&amp;lt;&amp;gt;(358) AND [wait_type]&amp;lt;&amp;gt;(202) AND [wait_type]&amp;lt;&amp;gt;(32) AND [wait_type]&amp;lt;&amp;gt;(868) AND [wait_type]&amp;lt;&amp;gt;(409) AND [wait_type]&amp;lt;&amp;gt;(752) AND [wait_type]&amp;lt;&amp;gt;(394) AND [wait_type]&amp;lt;&amp;gt;(398) AND [wait_type]&amp;lt;&amp;gt;(407) AND [wait_type]&amp;lt;&amp;gt;(408) AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server (Monitoring)') AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server (Monitoring 2)') AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server XEventsReader (Monitoring)'))),&lt;br&gt;
ADD EVENT sqlos.wait_info_external(&lt;br&gt;
    ACTION(package0.collect_system_time,sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_name,sqlserver.is_system,sqlserver.plan_handle,sqlserver.session_id,sqlserver.tsql_frame,sqlserver.username)&lt;br&gt;
    WHERE ([sqlserver].[is_system]=(0) AND [opcode]=(1) AND [duration]&amp;gt;(0) AND [wait_type]&amp;lt;&amp;gt;(755) AND [wait_type]&amp;lt;&amp;gt;(177) AND [wait_type]&amp;lt;&amp;gt;(413) AND [wait_type]&amp;lt;&amp;gt;(285) AND [wait_type]&amp;lt;&amp;gt;(359) AND [wait_type]&amp;lt;&amp;gt;(137) AND [wait_type]&amp;lt;&amp;gt;(132) AND [wait_type]&amp;lt;&amp;gt;(232) AND [wait_type]&amp;lt;&amp;gt;(231) AND [wait_type]&amp;lt;&amp;gt;(230) AND [wait_type]&amp;lt;&amp;gt;(356) AND [wait_type]&amp;lt;&amp;gt;(141) AND [wait_type]&amp;lt;&amp;gt;(140) AND [wait_type]&amp;lt;&amp;gt;(143) AND [wait_type]&amp;lt;&amp;gt;(144) AND [wait_type]&amp;lt;&amp;gt;(121) AND [wait_type]&amp;lt;&amp;gt;(813) AND [wait_type]&amp;lt;&amp;gt;(393) AND [wait_type]&amp;lt;&amp;gt;(296) AND [wait_type]&amp;lt;&amp;gt;(801) AND [wait_type]&amp;lt;&amp;gt;(839) AND [wait_type]&amp;lt;&amp;gt;(382) AND [wait_type]&amp;lt;&amp;gt;(151) AND [wait_type]&amp;lt;&amp;gt;(651) AND [wait_type]&amp;lt;&amp;gt;(767) AND [wait_type]&amp;lt;&amp;gt;(661) AND [wait_type]&amp;lt;&amp;gt;(855) AND [wait_type]&amp;lt;&amp;gt;(775) AND [wait_type]&amp;lt;&amp;gt;(857) AND [wait_type]&amp;lt;&amp;gt;(856) AND [wait_type]&amp;lt;&amp;gt;(884) AND [wait_type]&amp;lt;&amp;gt;(871) AND [wait_type]&amp;lt;&amp;gt;(854) AND [wait_type]&amp;lt;&amp;gt;(859) AND [wait_type]&amp;lt;&amp;gt;(858) AND [wait_type]&amp;lt;&amp;gt;(853) AND [wait_type]&amp;lt;&amp;gt;(873) AND [wait_type]&amp;lt;&amp;gt;(881) AND [wait_type]&amp;lt;&amp;gt;(782) AND [wait_type]&amp;lt;&amp;gt;(780) AND [wait_type]&amp;lt;&amp;gt;(841) AND [wait_type]&amp;lt;&amp;gt;(798) AND [wait_type]&amp;lt;&amp;gt;(799) AND [wait_type]&amp;lt;&amp;gt;(130) AND [wait_type]&amp;lt;&amp;gt;(786) AND [wait_type]&amp;lt;&amp;gt;(96) AND [wait_type]&amp;lt;&amp;gt;(816) AND [wait_type]&amp;lt;&amp;gt;(605) AND [wait_type]&amp;lt;&amp;gt;(1021) AND [wait_type]&amp;lt;&amp;gt;(991) AND [wait_type]&amp;lt;&amp;gt;(993) AND [wait_type]&amp;lt;&amp;gt;(883) AND [wait_type]&amp;lt;&amp;gt;(131) AND [wait_type]&amp;lt;&amp;gt;(283) AND [wait_type]&amp;lt;&amp;gt;(335) AND [wait_type]&amp;lt;&amp;gt;(347) AND [wait_type]&amp;lt;&amp;gt;(273) AND [wait_type]&amp;lt;&amp;gt;(100) AND [wait_type]&amp;lt;&amp;gt;(102) AND [wait_type]&amp;lt;&amp;gt;(107) AND [wait_type]&amp;lt;&amp;gt;(105) AND [wait_type]&amp;lt;&amp;gt;(109) AND [wait_type]&amp;lt;&amp;gt;(108) AND [wait_type]&amp;lt;&amp;gt;(754) AND [wait_type]&amp;lt;&amp;gt;(165) AND [wait_type]&amp;lt;&amp;gt;(348) AND [wait_type]&amp;lt;&amp;gt;(756) AND [wait_type]&amp;lt;&amp;gt;(392) AND [wait_type]&amp;lt;&amp;gt;(221) AND [wait_type]&amp;lt;&amp;gt;(800) AND [wait_type]&amp;lt;&amp;gt;(897) AND [wait_type]&amp;lt;&amp;gt;(358) AND [wait_type]&amp;lt;&amp;gt;(202) AND [wait_type]&amp;lt;&amp;gt;(32) AND [wait_type]&amp;lt;&amp;gt;(868) AND [wait_type]&amp;lt;&amp;gt;(409) AND [wait_type]&amp;lt;&amp;gt;(752) AND [wait_type]&amp;lt;&amp;gt;(394) AND [wait_type]&amp;lt;&amp;gt;(398) AND [wait_type]&amp;lt;&amp;gt;(407) AND [wait_type]&amp;lt;&amp;gt;(408) AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server (Monitoring)') AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server (Monitoring 2)') AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server XEventsReader (Monitoring)'))),&lt;br&gt;
ADD EVENT sqlserver.sp_statement_completed(SET collect_statement=(0)&lt;br&gt;
    ACTION(package0.collect_system_time,sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_name,sqlserver.plan_handle,sqlserver.session_id,sqlserver.username)&lt;br&gt;
    WHERE ([sqlserver].[is_system]=(0) AND [duration]&amp;gt;(0) AND ([physical_reads]&amp;gt;(0) OR [logical_reads]&amp;gt;(0) OR [writes]&amp;gt;(0) OR [cpu_time]&amp;gt;(0)) AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server (Monitoring)') AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server (Monitoring 2)') AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server XEventsReader (Monitoring)'))),&lt;br&gt;
ADD EVENT sqlserver.sql_statement_completed(SET collect_statement=(0)&lt;br&gt;
    ACTION(package0.collect_system_time,sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_name,sqlserver.plan_handle,sqlserver.session_id,sqlserver.username)&lt;br&gt;
    WHERE ([sqlserver].[is_system]=(0) AND [duration]&amp;gt;(0) AND ([physical_reads]&amp;gt;(0) OR [logical_reads]&amp;gt;(0) OR [writes]&amp;gt;(0) OR [cpu_time]&amp;gt;(0)) AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server (Monitoring)') AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server (Monitoring 2)') AND NOT [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[client_app_name],'Spotlight Diagnostic Server XEventsReader (Monitoring)'))),&lt;br&gt;
ADD EVENT sqlserver.xml_deadlock_report&lt;br&gt;
ADD TARGET package0.ring_buffer(SET max_events_limit=(1000),occurrence_number=(1000))&lt;br&gt;
WITH (MAX_MEMORY=8192 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=15 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=PER_NODE,TRACK_CAUSALITY=ON,STARTUP_STATE=OFF)&lt;br&gt;
GO&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We can also use other profilers, such as the one from &lt;a href="https://docs.microsoft.com/en-us/sql/tools/sql-server-profiler/sql-server-profiler?view=sql-server-ver15"&gt;Microsoft&lt;/a&gt; or those from third-party companies like &lt;a href="https://www.devart.com/dbforge/sql/studio/sql-server-event-profiler.html"&gt;Devart (Event Profiler for SQL Server)&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wC9cvU6W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wC9cvU6W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig5.png" alt="Fig.5 Selecting the tracing type-1" title="Fig.5 Selecting the tracing type-1" width="756" height="694"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YSyGcoON--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YSyGcoON--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig6.png" alt="Fig.6 Selecting the tracing type-2" title="Fig.6 Selecting the tracing type-2" width="757" height="694"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dz6UPBII--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dz6UPBII--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig7.png" alt="Fig.7 Selecting Execution" title="Fig.7 Selecting Execution" width="757" height="694"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zzLLyY0U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zzLLyY0U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig8.png" alt="Fig.8 Selecting actions" title="Fig.8 Selecting actions" width="800" height="731"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also specify filters:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Pi8JvAAI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Pi8JvAAI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig9.png" alt="Fig.9 Specifying tracing filters" title="Fig.9 Specifying tracing filters" width="757" height="694"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also configure what columns will be displayed:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ItoK3gxP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ItoK3gxP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig10.png" alt="Fig.10 Selecting columns" title="Fig.10 Selecting columns" width="757" height="694"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An example of a compiled trace file:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9iyzkcHi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9iyzkcHi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ondicesu.sirv.com/Images/Set%2520up%2520Extended%2520Events%2520in%2520SQL%2520Server/fig11.png" alt="Fig.11 Tracing results" title="Fig.11 Tracing results" width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>sqlserver</category>
    </item>
    <item>
      <title>The best way to synchronize (one way) a table in SQL Server</title>
      <dc:creator>Evgeniy Gribkov</dc:creator>
      <pubDate>Wed, 30 Sep 2020 09:31:23 +0000</pubDate>
      <link>https://dev.to/jobgemws/the-best-way-to-synchronize-one-way-a-table-in-sql-server-4f48</link>
      <guid>https://dev.to/jobgemws/the-best-way-to-synchronize-one-way-a-table-in-sql-server-4f48</guid>
      <description>&lt;p&gt;To synchronize two tables, you can use either built-in tools like &lt;a href="https://docs.microsoft.com/en-us/sql/integration-services/ssis-how-to-create-an-etl-package?view=sql-server-ver15" rel="noopener noreferrer"&gt;SSIS&lt;/a&gt; or third-party ones.&lt;br&gt;
You can learn about synchronizing table data one-way via &lt;a href="https://docs.microsoft.com/en-us/sql/integration-services/ssis-how-to-create-an-etl-package?view=sql-server-ver15" rel="noopener noreferrer"&gt;SSIS&lt;/a&gt; by referring to this link:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig1.png" title="Fig.1 Table data one-way synchronization package" alt="Fig.1 Table data one-way synchronization package"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also synchronize two tables with the help of a third-party tool called &lt;a href="https://www.devart.com/en/dbforge/sql/datacompare/" rel="noopener noreferrer"&gt;dbForge Data Compare&lt;/a&gt; that integrates with &lt;a href="https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15" rel="noopener noreferrer"&gt;SSMS&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig2.png" title="Fig.2 Comparing table data in SSMS" alt="Fig.2 Comparing table data in SSMS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before the comparison process starts, you can configure the source and target servers and databases:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig3.png" title="Fig.3 Setting up the source and the target" alt="Fig.3 Setting up the source and the target"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Column mapping can be set for the table:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig4.png" title="Fig.4 Column mapping" alt="Fig.4 Column mapping"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;“Columns details” displays column definition information from two tables: source database on the left and target database on the right.&lt;br&gt;
Column mapping is particularly useful when column names are different in the source and the target.&lt;/p&gt;

&lt;p&gt;As a result, we can see data differences:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig5.png" title="Fig.5 Data differences" alt="Fig.5 Data differences"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Column visibility and sorting can also be configured:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig6.png" title="Fig.6 Column visibility and sorting settings" alt="Fig.6 Column visibility and sorting settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can generate a script or perform data synchronization  after finding the differences.&lt;br&gt;
Keep in mind that it’s important to make sure table definitions match before comparing or synchronizing data between two tables. This can be done with the help of standard methods, like &lt;a href="https://visualstudio.microsoft.com/" rel="noopener noreferrer"&gt;Visual Studio&lt;/a&gt; or &lt;a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-ver15" rel="noopener noreferrer"&gt;SSDT&lt;/a&gt;, or via 3rd-party tools.&lt;/p&gt;

&lt;p&gt;To do this, you need to create a new SQL Server Database project as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig7.jpg" title="Fig.7 Creating a new SQL Server Database project" alt="Fig.7 Creating a new SQL Server Database project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, you’ll need to import the database:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig8.jpg" title="Fig.8 Opening the database import window" alt="Fig.8 Opening the database import window"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the window that will be opened, you need to configure a connection to the necessary database and then press &lt;em&gt;Start&lt;/em&gt; to initiate the import process:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig9.jpg" title="Fig.9 Configuring and  starting the database import process" alt="Fig.9 Configuring and  starting the database import process"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this, you will be able to see folders, subfolders, and definitions of database objects in the project:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig10.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig10.jpg" title="Fig.10 Project after import" alt="Fig.10 Project after import"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the same way, you will need to create a project and perform import for the second database.&lt;/p&gt;

&lt;p&gt;Now, to compare the database schemas, you just need to right-click any of the two projects and then click &lt;em&gt;Schema Compare&lt;/em&gt;… in the context menu:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig11.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig11.jpg" title="Fig.11 Navigating to the database schema comparison window" alt="Fig.11 Navigating to the database schema comparison window"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a result, a database schema comparison window will be opened.&lt;br&gt;
Here you need to select source and target projects and press &lt;em&gt;Compare&lt;/em&gt; to start the comparison process:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig12.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig12.jpg" title="Fig.12 Database schema comparison window" alt="Fig.12 Database schema comparison window"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, you can use other tools for database comparison, such as dbForge &lt;a href="https://www.devart.com/en/dbforge/sql/schemacompare/" rel="noopener noreferrer"&gt;Schema Compare&lt;/a&gt;, which integrates with &lt;a href="https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15" rel="noopener noreferrer"&gt;SSMS&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig13.png" title="Fig.13 Comparing database schemas in SSMS" alt="Fig.13 Comparing database schemas in SSMS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can configure the source and target for schema comparison:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig14.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig14.png" title="Fig.14 Configuring the source and target for schema comparison" alt="Fig.14 Configuring the source and target for schema comparison&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also set table mapping in the corresponding tab:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig15.png" title="Fig.15 Selecting a table for mapping" alt="Fig.15 Selecting a table for mapping"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig16.png" title="Fig.16 Configuring field mapping in the table" alt="Fig.16 Configuring field mapping in the table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;“Columns details” displays column definition information from two tables: source database on the left and target database on the right.&lt;/p&gt;

&lt;p&gt;This is particularly useful when column names are different in the source and the target.&lt;/p&gt;

&lt;p&gt;After schemas are compared, you can select the necessary table and see the table definition differences in two databases:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fondicesu.sirv.com%2FImages%2Ffig17.png" title="Fig.17 Table schema comparison between two databases" alt="Fig.17 Table schema comparison between two databases"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the bottom left, the definition code of the source database table is displayed, and that of the target database is displayed at the bottom right.&lt;/p&gt;

&lt;p&gt;If needed, a synchronization script for any schema table can be generated.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
    </item>
    <item>
      <title>How To Read a Transaction Log in a SQL Server</title>
      <dc:creator>Evgeniy Gribkov</dc:creator>
      <pubDate>Fri, 13 Mar 2020 16:51:56 +0000</pubDate>
      <link>https://dev.to/jobgemws/how-to-read-a-transaction-log-in-a-sql-server-49ho</link>
      <guid>https://dev.to/jobgemws/how-to-read-a-transaction-log-in-a-sql-server-49ho</guid>
      <description>&lt;p&gt;You can read the transaction log with the help of undocumented functions called fn_dblog и fn_dump_dblog:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I. fn_dblog&lt;/strong&gt; – an undocumented SQL Server function that allows you to monitor the active part of the transaction log in real time.&lt;/p&gt;

&lt;p&gt;Let’s execute the following query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Select top(100) * FROM sys.fn_dblog(NULL,NULL)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ihAhkuBz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/6fg5mus4jn0wlv43n1xr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ihAhkuBz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/6fg5mus4jn0wlv43n1xr.jpg" alt="Monitor the active part" width="800" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Usually, the amount of retrieved data is very large, so it’s better to filter it. For example, let’s select only those transactions that insert rows into a table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT top(100) [Current LSN],
       [Operation],
       [Context],
       [Transaction ID],
       [Begin time]
       FROM sys.fn_dblog
   (NULL, NULL)
  WHERE operation IN
   ('LOP_INSERT_ROWS');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s a possible result of such a query:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AR2-or30--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/9ai2q122ob7yt09miqia.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AR2-or30--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/9ai2q122ob7yt09miqia.jpg" alt="filtering retrieved data" width="563" height="118"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can retrieve all row deletion transactions in a similar way using this query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT top(100) [begin time],
       [rowlog contents 1],
       [Transaction Name],
       Operation
  FROM sys.fn_dblog
   (NULL, NULL)
  WHERE operation IN
   ('LOP_DELETE_ROWS');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the set resulting from this query, rows will look similar to the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JoVK7Ucn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ekbs2q8esz3btwe5qz3e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JoVK7Ucn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ekbs2q8esz3btwe5qz3e.jpg" alt="retrieving all row deletion transactions" width="800" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The information about inserted or deleted rows will be stored in these columns:&lt;br&gt;
    • RowLog Contents 0&lt;br&gt;
    • RowLog Contents 1&lt;br&gt;
    • RowLog Contents 2&lt;br&gt;
    • RowLog Contents 3&lt;br&gt;
    • RowLog Contents 4&lt;br&gt;
    • Description&lt;br&gt;
    • Log Record&lt;/p&gt;

&lt;p&gt;Different columns are used for each transaction type. To get the required info, you need to know which columns are used for which transactions, but it can be rather difficult because there’s no official documentation describing this.&lt;br&gt;
Inserted and deleted rows are stored as HEX values. To extract data from these values, you need to know the format they’re stored in, understand state bits, know the total number of columns, etc.&lt;/p&gt;

&lt;p&gt;Next, we need to convert binary data to a table while considering column data types. The conversion method is different for all data types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;fn_dbLog&lt;/strong&gt; is a great free tool that allows you to read transaction logs. However, this functionality has some caveats – it’s difficult to navigate through the data as it contains records about system tables, only the active part of the log is displayed, and there’s no information on updates of BLOB values.&lt;/p&gt;

&lt;p&gt;With minimal transaction log protocolling, the UPDATE operation does not contain the full values before and after changes, but rather stores only the part that was changed (SQL Server can write that a value was changed from ‘G’ to ‘D’, while in reality, the word ‘GLOAT’ was changed to ‘FLOAT’ ). In this case, you would need to manually restore all intermediary states of the record from the moment it was inserted to the moment you’re interesed in.&lt;/p&gt;

&lt;p&gt;When a BLOB object is deleted, it’s not written to the log – only the fact that it was deleted will be recorded. To restore a deleted BLOB object, you need to find a pair for this deletion in the log. It’s a previously performed insertion which is, most probably, not stored in the log’s active part anymore.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;II. fn_dump_dblog&lt;/strong&gt; – as of yet, an undocumented function that allows you to look through the transaction log from it’s backup copy (either a compressed or uncompressed one):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT top(100) [Current LSN],
       [Operation],
       [Context],
       [Transaction ID],
     [transaction name],
       [Description]
FROM fn_dump_dblog
(NULL,NULL,N'DISK',1,N'E:\Backups\JobEmpl.bak',
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
DEFAULT);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fn_dump_dblog function, just as fn_dblog, returns 129 columns. This is why it’s important to specify the necessary columns in the query.&lt;/p&gt;

&lt;p&gt;However, the limitations here are the same as with the fn_dbLog function, including data decryption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;III. DBCC PAGE&lt;/strong&gt; – an undocumented function that allows you to look through the contents of MDF and LDF files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DBCC PAGE ( {'dbname' | dbid}, filenum, pagenum [, printopt={0|1|2|3} ])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, the result of the DBCC PAGE command is not displayed in SQL Server Management Studio by default. To display this result properly, the trace flag 3604 should be turned on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DBCC TRACEON (3604, -1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this, you can execute the desired command.&lt;/p&gt;

&lt;p&gt;DBCC PAGE has the same limitations as previously described functions when it comes to data decryption.&lt;/p&gt;

&lt;p&gt;However, a more convenient approach is to use off-the-shelf solutions for reading transaction logs and rolling back changes. For instance, the RedGate SQL Log Rescue or &lt;a href="https://www.devart.com/dbforge/sql/transaction-log/"&gt;dbForge Transaction Log&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>transactionlog</category>
      <category>database</category>
      <category>dba</category>
    </item>
    <item>
      <title>Comparison of Two Database Schemas in SQL Server</title>
      <dc:creator>Evgeniy Gribkov</dc:creator>
      <pubDate>Thu, 12 Mar 2020 15:25:34 +0000</pubDate>
      <link>https://dev.to/jobgemws/comparison-of-two-database-schemas-in-sql-server-42n6</link>
      <guid>https://dev.to/jobgemws/comparison-of-two-database-schemas-in-sql-server-42n6</guid>
      <description>&lt;p&gt;To synchronize the schemas of two databases, you can use both standard approaches like &lt;a href="https://visualstudio.microsoft.com/"&gt;Visual Studio&lt;/a&gt; and &lt;a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-ver15"&gt;SSDT&lt;/a&gt; and third-party tools.&lt;/p&gt;

&lt;p&gt;This is how you can do it in Visual Studio:&lt;/p&gt;

&lt;p&gt;First of all, Create a SQL Server Database project:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jDkwA7Fa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/xxyxmg88079nnfwo14c3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jDkwA7Fa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/xxyxmg88079nnfwo14c3.jpg" alt="Creating a SQL Server Database project" width="800" height="555"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.1 Creating a SQL Server Database project&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then import the database:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pxiOOXuF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/i2rzskauha40o6ikv4hi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pxiOOXuF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/i2rzskauha40o6ikv4hi.jpg" alt="Navigating to the database import window" width="604" height="591"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.2 Navigating to the database import window&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the window that will be opened, configure the connection to the necessary database and press &lt;strong&gt;Start&lt;/strong&gt; to initiate the import process:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MPzSiFEs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/a4g8f75osbz1e1pqoki5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MPzSiFEs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/a4g8f75osbz1e1pqoki5.jpg" alt="Configuring and starting the database import process" width="670" height="436"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.3 Configuring and starting the database import process&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After this, you will be able to see folders, subfolders, and definitions of database objects in the project:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yQhFpATE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ntdaak7v6jdgo91yyqmw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yQhFpATE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ntdaak7v6jdgo91yyqmw.jpg" alt="Project after import" width="341" height="363"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.4 Project after import&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the same way, you will need to create a project and perform import for the second database.&lt;/p&gt;

&lt;p&gt;Now, to compare the database schemas, you just need to right-click any of the two projects and then click &lt;strong&gt;Schema Compare&lt;/strong&gt;… in the context menu:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gyYJYtu3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/xso1lx4t3iww3brqdo0p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gyYJYtu3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/xso1lx4t3iww3brqdo0p.jpg" alt="Navigating to the database schema comparison window" width="494" height="363"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.5 Navigating to the database schema comparison window&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As a result, the database schema comparison window will be opened.&lt;br&gt;
Here you need to select source and target projects and then press &lt;strong&gt;Compare&lt;/strong&gt; to initiate the comparison process:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pH05MCwV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/rkmfb3jxndct7ndh8nzv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pH05MCwV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/rkmfb3jxndct7ndh8nzv.jpg" alt="Database schema comparison window" width="800" height="418"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.6 Database schema comparison window&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can also use other tools to compare database schemas, such as &lt;a href="https://www.devart.com/dbforge/sql/schemacompare/"&gt;dbForge Schema Compare&lt;/a&gt; which integrates with &lt;a href="https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15"&gt;SSMS&lt;/a&gt; and is included in the &lt;a href="https://www.devart.com/dbforge/sql/sql-tools/"&gt;SQL Tools&lt;/a&gt; bundle:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MmHT3Ukk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/uvihwgu0bb96s2mg457p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MmHT3Ukk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/uvihwgu0bb96s2mg457p.jpg" alt="Comparing database schemas in SSMS" width="800" height="557"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.7 Comparing database schemas in SSMS&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here you can configure the source and target for schema comparison:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JvptdZ-t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/23bla5l44x652k4bq3wi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JvptdZ-t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/23bla5l44x652k4bq3wi.jpg" alt="Configuring the source and target for schema comparison" width="800" height="720"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.8 Configuring the source and target for schema comparison&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Table mapping can be configured in the corresponding tab:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QCcEbHBX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/mmbet3ixzyzgw6kfhcv6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QCcEbHBX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/mmbet3ixzyzgw6kfhcv6.jpg" alt="Selecting a table for mapping" width="800" height="716"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.9 Selecting a table for mapping&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zlg5SuLu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ka1lauks307ngjpgaihd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zlg5SuLu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ka1lauks307ngjpgaihd.jpg" alt="Configuring field mapping in the table" width="656" height="1000"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.10 Configuring field mapping in the table&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;“Columns details” displays column definition information from two tables: source database on the left and target database on the right.&lt;/p&gt;

&lt;p&gt;This is particularly useful when column names are different in the source and the target.&lt;/p&gt;

&lt;p&gt;After schemas are compared, you can select the necessary table and see the table definition differences in two databases:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E_UEo7t2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/w7uj8s5pvhr5znklx1dg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E_UEo7t2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/w7uj8s5pvhr5znklx1dg.jpg" alt="Table schema comparison between two databases" width="800" height="381"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Fig.11 Table schema comparison between two databases&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;At the bottom left, the definition code of the source database table is displayed, and that of the target database is displayed at the bottom right.&lt;/p&gt;

&lt;p&gt;If needed, a synchronization script for any schema table can be generated.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>visualstudio</category>
      <category>schema</category>
    </item>
  </channel>
</rss>
