diff --git a/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.exe b/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.exe
index 2648bc7..a390811 100644
Binary files a/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.exe and b/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.exe differ
diff --git a/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.exe.config b/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.exe.config
index 1fcd7a9..3706859 100644
--- a/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.exe.config
+++ b/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.exe.config
@@ -4,10 +4,8 @@
-
-
-
-
+
+
@@ -16,21 +14,21 @@
-
-
-
+
-
+
+
+
\ No newline at end of file
diff --git a/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.zip b/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.zip
new file mode 100644
index 0000000..e30b5bd
Binary files /dev/null and b/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Converter.zip differ
diff --git a/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Schema Converter Utility.docx b/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Schema Converter Utility.docx
new file mode 100644
index 0000000..894109d
Binary files /dev/null and b/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza Schema Converter Utility.docx differ
diff --git a/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza_DDL_Converter.docx b/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza_DDL_Converter.docx
deleted file mode 100644
index f180ecb..0000000
Binary files a/IP and Scripts/Netezza DDL Converter Utility/Netezza DDL Converter Utility/Netezza_DDL_Converter.docx and /dev/null differ
diff --git a/IP and Scripts/Netezza DDL Converter Utility/READ ME.txt b/IP and Scripts/Netezza DDL Converter Utility/READ ME.txt
deleted file mode 100644
index 6d829f3..0000000
--- a/IP and Scripts/Netezza DDL Converter Utility/READ ME.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-The Netezza DDL converter utility is tool to convert Netezza database schema DDL to SQL equivalent.
-The highlight of this utility is that it can convert Netezza MPP DDL to SQL MPP or SMP equivalent,
-which means it supports the conversion to Azure SQL DW, Azure SQL DB, Azure SQL MI and SQL Server on-premises.
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/MICROSOFT LICENSE TERMS.docx b/IP and Scripts/SQLServiceBusPOC/MICROSOFT LICENSE TERMS.docx
new file mode 100644
index 0000000..f9f6bc9
Binary files /dev/null and b/IP and Scripts/SQLServiceBusPOC/MICROSOFT LICENSE TERMS.docx differ
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/Configure MI Sales Orders triggers.sql b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/Configure MI Sales Orders triggers.sql
new file mode 100644
index 0000000..2eb254d
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/Configure MI Sales Orders triggers.sql
@@ -0,0 +1,70 @@
+USE [WideWorldImporters]
+GO
+CREATE ASSEMBLY [SendSBMsg]
+FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C010300CA9E9DA20000000000000000E00022200B013000002000000006000000000000923F00000020000000400000000000100020000000020000040000000000000006000000000000000080000000020000110F01000300608500001000001000000000100000100000000000001000000000000000000000003E3F00004F0000000040000078030000000000000000000000280000C0050000006000000C0000009C3E0000380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E74657874000000981F0000002000000020000000020000000000000000000000000000200000602E7273726300000078030000004000000004000000220000000000000000000000000000400000402E72656C6F6300000C0000000060000000020000002600000000000000000000000000004000004200000000000000000000000000000000723F0000000000004800000002000500282600007418000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001B300500290300000100001100280F00000A0A72010000700B72010000700C281000000A1306281100000A13077203000070731200000A1308000011086F1300000A0072330000701108731400000A251304130A001104176F1500000A251305130B0011056F1600000A130C110C2C14001105166F1700000A0B1105176F1700000A0C0011056F1800000A0000DE0D110B2C08110B6F1900000A00DC00DE0D110A2C08110A6F1900000A00DC7272020070087296020070281A00000A0D11066F1B00000A19FE01130D110D2C1D0072AA02007013090972D6020070077214030070281C00000A0D002B1B0072320300701309097260030070077214030070281C00000A0D0011091108731400000A251304130E001104176F1500000A251305130F00388E0000000009729E030070281D00000A0D1613102B5E00110511106F1E00000A13111E8D26000001251609A2251772AA030070A225181111A2251972AE030070A2251A110511106F1F00000A6F2000000AA2251B72B2030070A2251C1111A2251D72AE030070A2282100000A0D00111017581310111011056F2200000AFE04131211122D910972B8030070281D00000A0D0011056F1600000A131311133A62FFFFFF00DE0D110F2C08110F6F1900000A00DC11056F1800000A0000DE0D110E2C08110E6F1900000A00DC0972C6030070281D00000A0D00DE21131400110772EA03007011146F2300000A281D00000A6F2400000A00DD1701000011086F2500000A0011077202040070280F00000A1315121506282600000A13161216282700000A13171217282800000A281D00000A6F2400000A0000DE0D11082C0811086F1900000A00DC000028020000061318732900000A131911196F2A00000A1F1811186F2B00000A0011196F2A00000A1F0C722A0400706F2B00000A00282C00000A096F2D00000A131A111972860400707200050070111A6F2E00000A261119121B2803000006131C111C202B010000FE02131D111D2C1B1107121C282F00000A720A050070111B281A00000A6F2400000A0000DE3E131E0011077210050070111E2804000006281D00000A6F2400000A0000DE1F131F00110772EA030070111F6F2300000A281D00000A6F2400000A0000DE002A00000041C4000002000000560000002D000000830000000D0000000000000002000000480000004B000000930000000D000000000000000200000015010000A7000000BC0100000D000000000000000200000007010000CD000000D40100000D00000000000000000000002E000000C2010000F00100002100000017000001020000002D000000220200004F0200000D00000000000000000000005D0200008D000000EA0200001F0000001A000001000000005D0200008D000000090300001F0000001700000113300800CA0000000200001100120020B2070000171716161616283000000A280F00000A13061206283100000A06283200000A0B1201283300000A283400000A20B0040000580C7230050070283500000A72700500701202283600000A281A00000A0D282C00000A72740500706F2D00000A733700000A13041104282C00000A096F2D00000A6F3800000A283900000A1305283A00000A72CE0500701A8D1000000125167230050070283500000AA225171105283500000AA22518088C2F000001A225197236060070A2283B00000A13072B0011072A000013300300540000000300001100026F3C00000A726A0600701F246F3D00000A0A0614283E00000A0B072C2A0006026F3F00000A751D0000010C0814FE030D092C130003086F4000000A51086F4100000A13042B09000314511613042B0011042A1B3004007C0000000400001100026F2300000A0A00026F4200000A741D0000010B076F4300000A0C734400000A0D08096F4500000A00096F4600000A1304282C00000A11046F4700000A7286060070076F4100000A13051205FE16200000016F2000000A72AA060070281C00000A0A00DE0E13060011066F2300000A0A00DE000613072B0011072A01100000000008005E66000E170000012202284800000A002A00000042534A4201000100000000000C00000076342E302E33303331390000000005006C000000A0040000237E00000C050000B006000023537472696E677300000000BC0B0000B0060000235553006C1200001000000023475549440000007C120000F805000023426C6F620000000000000002000001571D02000900000000FA01330016000001000000350000000200000005000000050000000300000048000000050000000E0000000400000001000000030000000000200301000000000006002E02540506009B02540506006201FB040F007405000006008A01BB0306001102BB030600F201BB0306008202BB0306004E02BB0306006702BB030600A101BB030600760135050600540135050600D501BB030600BC01CB020600C80556030600E20056030A006300E4050A009E04E4050A004206CA040A000401CA040A00EE03E40506001504560306006B0356030E00DA05CF050E00FC03CF0506000A006F0606006104BB030E003601CF05060046032B00060040032B000E008C00CF050A002406CA040A00E10347040A00E50435000A00910447040600BF0056030600000356030A009E03CA040600CB0056030E00CD03CF050E007F04CF050600C20218060600040056030600100656030E00A306CF0506000300560306005D036F0606006B0485030600BA04560306000F01560306008C05BB030E003A01CF05000000001E00000000000100010001001000A505000041000100010051802700F90451807300F9045180DA00F90451806406F90451808C06F90450200000000096000703FC0401004C2400000000910074030005010024250000000091009B0004050100842500000000910009040C0503001C26000000008618F5040600040000000100FA050200020035040000010077040900F50401001100F50406001900F5040A002900F50410003100F50410003900F50410004100F50410004900F50410005100F50410005900F50410006100F50415006900F50410007100F50410007900F5041000890054064E0009012F0653000901FB005800B100F50410001101800306009100F5045D009100AC046400210155006C002101FD02700021014601060029014C0106003101B1057500A1009A037C003101B10582003101B1058A002101D20070002101B90290008100F40295003101B1059900210101069F00B900B3009500A9006E0010001101460106008900BF05A300C1001F05AA004101F4029500C900F5040600C9009905AE0049014D03B40059011500BC0059018305C200C9004100C8006101F40295008900F504E0008900EB00EB008900AC03F000C1000E05AA0069010100F9007101A900FE007901F4029500D900F50403018101140309016901E50210018901140116013101B8051C0181000C01300199015A003601E10095063F01E100B9024701E9001F049500E9007D004C01D10029016401A9012E036A01F900F5040600F1005A046F01F9005C0675015901FD027A018100F50406000E00040089010E000800F0010E000C002F020E00100062020E001400BB022E000B0012052E0013001B052E001B003A052E00230043052E002B0052052E00330052052E003B0052052E00430043052E004B0058052E00530052052E005B0052052E00630070052E006B009A052E007300A7051A00D100260152010480000001000000000000000000000000000A03000004000000000000000000000080014C000000000004000000000000000000000080013500000000000400000000000000000000008001560300000000000000546F55496E74333200484D4143534841323536006765745F55544638003C4D6F64756C653E005552490053797374656D2E494F0053797374656D2E446174610055706C6F616444617461006D73636F726C69620052656164004765744669656C640053716C436F6D6D616E640053656E64004E616D657370616365006765745F537461747573436F64650048747470537461747573436F646500476574537461747573436F64650055726C456E636F6465006765745F4D6573736167650049446973706F7361626C6500446F75626C65004765744E616D65004B65794E616D65004461746554696D6500546F556E6976657273616C54696D65006765745F506970650053716C506970650047657454797065006765745F496E76617269616E7443756C74757265006765745F526573706F6E73650048747470576562526573706F6E736500436C6F736500446973706F736500477569644174747269627574650044656275676761626C6541747472696275746500436F6D56697369626C6541747472696275746500417373656D626C795469746C6541747472696275746500417373656D626C7954726164656D61726B417474726962757465005461726765744672616D65776F726B41747472696275746500417373656D626C7946696C6556657273696F6E41747472696275746500417373656D626C79436F6E66696775726174696F6E41747472696275746500417373656D626C794465736372697074696F6E41747472696275746500436F6D70696C6174696F6E52656C61786174696F6E7341747472696275746500417373656D626C7950726F6475637441747472696275746500417373656D626C79436F7079726967687441747472696275746500417373656D626C79436F6D70616E794174747269627574650052756E74696D65436F6D7061746962696C6974794174747269627574650047657456616C756500456E636F64696E670053797374656D2E52756E74696D652E56657273696F6E696E6700546F426173653634537472696E6700546F537472696E6700476574537472696E670074726753656E6453424D736700436F6D70757465486173680053656E6453424D73672E646C6C00476574526573706F6E736553747265616D004D656D6F727953747265616D007365745F4974656D0053797374656D0048617368416C676F726974686D0054696D655370616E00476574536173546F6B656E004F70656E0053797374656D2E476C6F62616C697A6174696F6E006765745F54726967676572416374696F6E006F705F5375627472616374696F6E0053797374656D2E5265666C656374696F6E00576562486561646572436F6C6C656374696F6E004462436F6E6E656374696F6E0053716C436F6E6E656374696F6E00576562457863657074696F6E004765744572726F7246726F6D457863657074696F6E006765745F5374617475734465736372697074696F6E007374617475734465736372697074696F6E0053797374656D2E446174612E436F6D6D6F6E00436F7079546F004669656C64496E666F0043756C74757265496E666F0077656245786370004874747052657175657374486561646572004462446174615265616465720053716C4461746152656164657200457865637574655265616465720049466F726D617450726F7669646572004D6963726F736F66742E53716C5365727665722E53657276657200436F6D6D616E644265686176696F72002E63746F720053797374656D2E446961676E6F7374696373006765745F546F74616C5365636F6E6473006765745F546F74616C4D696C6C697365636F6E64730053797374656D2E52756E74696D652E496E7465726F7053657276696365730053797374656D2E52756E74696D652E436F6D70696C6572536572766963657300446562756767696E674D6F6465730047657442797465730042696E64696E67466C616773006765745F4865616465727300434C52547269676765727300436F6E63617400466F726D6174005375627472616374004F626A6563740053797374656D2E4E657400576562436C69656E740053797374656D2E446174612E53716C436C69656E7400636C69656E74006765745F4669656C64436F756E7400436F6E766572740053797374656D2E546578740053716C436F6E74657874006765745F54726967676572436F6E746578740053716C54726967676572436F6E74657874006765745F4E6F7700546F4172726179004163636F756E744B65790053797374656D2E53656375726974792E43727970746F6772617068790074626C7175657279006F705F496E657175616C697479005765625574696C6974790000000001002F63006F006E007400650078007400200063006F006E006E0065006300740069006F006E003D00740072007500650000823D530045004C00450043005400200027005B00270020002B00200073002E005B006E0061006D0065005D0020002B00200027005D002E005B00270020002B0020006F002E005B006E0061006D0065005D0020002B00200027005D0027002C0020005200450050004C004100430045002800400040005300450052005600450052004E0041004D0045002C002000270027002C0020002700250035004300270029002000460052004F004D0020007300790073002E0064006D005F007400720061006E005F006C006F0063006B00730020006C0020006A006F0069006E0020007300790073002E006F0062006A00650063007400730020006F0020006F006E00200028006C002E007200650073006F0075007200630065005F006100730073006F006300690061007400650064005F0065006E0074006900740079005F00690064003D0020006F002E006F0062006A006500630074005F0069006400290020006A006F0069006E0020007300790073002E0073006300680065006D00610073002000730020006F006E00200028006F002E0073006300680065006D0061005F00690064003D00200073002E0073006300680065006D0061005F00690064002900200057004800450052004500200072006500710075006500730074005F00730065007300730069006F006E005F006900640020003D002000400040007300700069006400200061006E00640020007200650073006F0075007200630065005F00740079007000650020003D00200027004F0042004A00450043005400270001233C006D006500730073006100670065003E003C007300650072007600650072003E0000133C002F007300650072007600650072003E00002B530045004C0045004300540020002A002000460052004F004D002000440045004C004500540045004400003D3C0061006300740069006F006E003E00640065006C006500740065003C002F0061006300740069006F006E003E003C007400610062006C0065003E00001D3C002F007400610062006C0065003E003C0072006F00770073003E00002D530045004C0045004300540020002A002000460052004F004D00200049004E00530045005200540045004400003D3C0061006300740069006F006E003E0069006E0073006500720074003C002F0061006300740069006F006E003E003C007400610062006C0065003E00000B3C0072006F0077003E0000033C0000033E0000053C002F00000D3C002F0072006F0077003E0000233C002F0072006F00770073003E003C002F006D006500730073006100670065003E00001745007800630065007000740069006F006E003A002000002745006C00610070007300650064002000540069006D006500200028006D00730029003A002000005B6100700070006C00690063006100740069006F006E002F00610074006F006D002B0078006D006C003B0074007900700065003D0065006E007400720079003B0063006800610072007300650074003D007500740066002D0038000179680074007400700073003A002F002F006D00760068007300620070006F0063002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E00650074002F007400610062006C0065006300680061006E00670065002F006D006500730073006100670065007300000950004F005300540000053A002000001F570065006200200045007800630065007000740069006F006E003A002000003F6D00760068007300620070006F0063002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E006500740000030A00005974004B0075003500740034003900750047004C0074007A0059005700580055006D0062006B006500650053006A007600470046002B006F006C006E006C0046004A0070005100450045007000460062003600490041003D0000675300680061007200650064004100630063006500730073005300690067006E00610074007500720065002000730072003D007B0030007D0026007300690067003D007B0031007D002600730065003D007B0032007D00260073006B006E003D007B0033007D00003352006F006F0074004D0061006E006100670065005300680061007200650064004100630063006500730073004B0065007900001B6D005F0057006500620052006500730070006F006E0073006500002320002800480074007400700053007400610074007500730043006F0064006500200000032900000000CDCD3D959810C940B6E0F4131355BA5500042001010803200001052001011111042001010E042001010233072011450E0E0E1249124D1251125512590E1249124D02021249124D080E0202125D114511610D0E12651D050E08021269125D040000114504000012510400001255062002010E1259072001124D11808D032000020420010E080600030E0E0E0E05200011809D0700040E0E0E0E0E0500020E0E0E0420011C080320000E0500010E1D0E03200008062001116111450320000D0520001280A5072002011180A90E0500001280AD0520011D050E0820031D050E0E1D050E070811451161090E126D0E11450E0A200701080808080808080420001145080002116111451145040001090D0400010E0E052001011D050620011D051D050500010E1D050500001280C50900030E1280C90E1D1C090705127102127502080520001280CD08200212710E1180D107000202127112710420011C1C0520001180811107080E12751279127D1D05118081125D0E0520001280D504200012790520010112790420001D050520010E1D0508B77A5C561934E08966680074007400700073003A002F002F006D00760068007300620070006F0063002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E00650074002F007400610062006C0065006300680061006E00670065003E6D00760068007300620070006F0063002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E00650074003252006F006F0074004D0061006E006100670065005300680061007200650064004100630063006500730073004B00650079005874004B0075003500740034003900750047004C0074007A0059005700580055006D0062006B006500650053006A007600470046002B006F006C006E006C0046004A0070005100450045007000460062003600490041003D00823C530045004C00450043005400200027005B00270020002B00200073002E005B006E0061006D0065005D0020002B00200027005D002E005B00270020002B0020006F002E005B006E0061006D0065005D0020002B00200027005D0027002C0020005200450050004C004100430045002800400040005300450052005600450052004E0041004D0045002C002000270027002C0020002700250035004300270029002000460052004F004D0020007300790073002E0064006D005F007400720061006E005F006C006F0063006B00730020006C0020006A006F0069006E0020007300790073002E006F0062006A00650063007400730020006F0020006F006E00200028006C002E007200650073006F0075007200630065005F006100730073006F006300690061007400650064005F0065006E0074006900740079005F00690064003D0020006F002E006F0062006A006500630074005F0069006400290020006A006F0069006E0020007300790073002E0073006300680065006D00610073002000730020006F006E00200028006F002E0073006300680065006D0061005F00690064003D00200073002E0073006300680065006D0061005F00690064002900200057004800450052004500200072006500710075006500730074005F00730065007300730069006F006E005F006900640020003D002000400040007300700069006400200061006E00640020007200650073006F0075007200630065005F00740079007000650020003D00200027004F0042004A00450043005400270002060E030000010300000E070002081265100E0500010E12690801000800000000001E01000100540216577261704E6F6E457863657074696F6E5468726F7773010801000701000000000E01000953656E6453424D7367000005010000000017010012436F7079726967687420C2A920203230313900002901002432353663333934392D333037332D343065632D393738302D32623233316637333539306400000C010007312E302E302E3000004D01001C2E4E45544672616D65776F726B2C56657273696F6E3D76342E372E320100540E144672616D65776F726B446973706C61794E616D65142E4E4554204672616D65776F726B20342E372E320000000000000064C0269100000000020000006A000000D43E0000D420000000000000000000000000000010000000000000000000000000000000525344530E39B6D5D040A644B392F707487F0B4501000000433A5C55736572735C6D6976616E6875755C736F757263655C7265706F735C53514C53657276696365427573504F435C53656E6453424D73675C6F626A5C44656275675C53656E6453424D73672E70646200663F00000000000000000000803F0000002000000000000000000000000000000000000000000000723F0000000000000000000000005F436F72446C6C4D61696E006D73636F7265652E646C6C00000000000000FF25002000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001001000000018000080000000000000000000000000000001000100000030000080000000000000000000000000000001000000000048000000584000001C03000000000000000000001C0334000000560053005F00560045005200530049004F004E005F0049004E0046004F0000000000BD04EFFE00000100000001000000000000000100000000003F000000000000000400000002000000000000000000000000000000440000000100560061007200460069006C00650049006E0066006F00000000002400040000005400720061006E0073006C006100740069006F006E00000000000000B0047C020000010053007400720069006E006700460069006C00650049006E0066006F0000005802000001003000300030003000300034006200300000001A000100010043006F006D006D0065006E007400730000000000000022000100010043006F006D00700061006E0079004E0061006D00650000000000000000003C000A000100460069006C0065004400650073006300720069007000740069006F006E0000000000530065006E006400530042004D00730067000000300008000100460069006C006500560065007200730069006F006E000000000031002E0030002E0030002E00300000003C000E00010049006E007400650072006E0061006C004E0061006D0065000000530065006E006400530042004D00730067002E0064006C006C0000004800120001004C006500670061006C0043006F007000790072006900670068007400000043006F0070007900720069006700680074002000A90020002000320030003100390000002A00010001004C006500670061006C00540072006100640065006D00610072006B007300000000000000000044000E0001004F0072006900670069006E0061006C00460069006C0065006E0061006D0065000000530065006E006400530042004D00730067002E0064006C006C00000034000A000100500072006F0064007500630074004E0061006D00650000000000530065006E006400530042004D00730067000000340008000100500072006F006400750063007400560065007200730069006F006E00000031002E0030002E0030002E003000000038000800010041007300730065006D0062006C0079002000560065007200730069006F006E00000031002E0030002E0030002E00300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000C000000943F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C005000000020200308205B106092A864886F70D010702A08205A23082059E020101310B300906052B0E03021A0500304C060A2B060104018237020104A03E303C3017060A2B06010401823702010F3009030100A004A20280003021300906052B0E03021A05000414B1739EEC61EF2F648E050EE5A41CB534329D6190A082036E3082036A30820256A00302010202106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021D0500303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C5220436572743020170D3139303930343230333432385A180F32303939313233313034303030305A303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C52204365727430820122300D06092A864886F70D01010105000382010F003082010A0282010100BFA0F1A347A83B886B753FA158B65426B1DEECB2C46A9660135BDA45F56F8714800C515BE1609962B57A575E5A4339683CE1665C0E2E3812F6F6958EF96FE97893BD778D4230516005FE682CF5C263E6638A45B21F8F15CC07927B7937796E56591B1D706DF6726D84C646027C5FF28D2B567627A72E0DA6DDF41808D0DF9281E47E9C8AE007CF4DBAD4E349179A1C9FC3E9DD62EC9C448E9CFD3AA9E2DAE3DB9E86A028CFA1C24885C7DFA45FA9C8B35A98ED2EF31A3F5DDD30E03B6E64B1F135BAFA1FAB08199DD5DFAE0F894544100B91AECB117101DAA49E526A309B6915DD822C0285B24F3CFA2BF89088984E21B6674C2B1692B395985C0B51D9EF07D90203010001A370306E306C0603551D01046530638010F4A197D3F4E3ECF1D4E1E0417E935184A13D303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C52204365727482106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021D05000382010100853E32A6278392ECF28EABD5EB9F2297D3282949818DD9CF4E175AB32D9588B2B144A920D630788E10CBF66DF0A135E43FCD36892F1E779D6D9EEA3CDC417C480D9A95257313C79678235019A419DF1F61E085D5B23CADDEDA108B16DF4C6C31658D56816A85424D90F6F715C271C9A6A642CE987841B31F41CFB2522CAC23C3D69DC6B9D8F5ED237E756425BBE288ADF80F1BE6971A7A0CA3BE442461B17DA9DF975798B1642F1686DD962DDAF341C76697A98E403F812311AA0B146580E458C9301E7BE02E2D33511F2461591A6FD163F8E78AD80E79B58B9D5F7CBBE386DE0F7E610A305777FB35BD1B6C4F55CCD11A5E9F04C5558DA24A62BEDBE98A7EE3318201CA308201C6020101304F303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C52204365727402106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021A0500A0523010060A2B06010401823702010C31023000301906092A864886F70D010903310C060A2B060104018237020104302306092A864886F70D010904311604146E44D767FCBD0FC763F8F729C2CA2067C3248ABB300D06092A864886F70D010101050004820100B44B082A2B71353A86CBF13444041B746F863BF0ADD52985EB05D71AAA6C60EFC94F770CB2C76A2967CE28F658483FC0B78234AE69C88F7DEDC23A44A6245BA2F193AFFA93271D8A5F34224824107F2C11E1A1806CE568E2CE1D0105F201DB21A83FD425E7F4C8BBB08B3B138B83736B94459423910AA32DED35CC239D69E03C46D6DC7E298440083246A72F660C0D0C6D0594D588C218568F52C3665F64756A99DDDD326C3C5AD464D511F4752CDC89F1A12EECC1D5E475AD55972EADE0754C9FA34FC1BDA850E8093334810C77F7A999ACC0A8274708FCEB7BF0054143A49B5D3C4658176EA7495D9AA28913A68DDBC52C210DB6774B2437F8930F7A8ECD8A000000
+WITH PERMISSION_SET = UNSAFE
+GO
+DROP ASSEMBLY SendSBMsgUDF
+GO
+CREATE ASSEMBLY [SendSBMsgUDF]
+FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C010300F497E3970000000000000000E00022200B013000001600000008000000000000E63500000020000000400000000000100020000000020000040000000000000006000000000000000080000000020000BF4A0000030060850000100000100000000010000010000000000000100000000000000000000000913500004F000000004000002C040000000000000000000000200000C0050000006000000C000000B8340000380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E74657874000000EC150000002000000016000000020000000000000000000000000000200000602E727372630000002C040000004000000006000000180000000000000000000000000000400000402E72656C6F6300000C0000000060000000020000001E00000000000000000000000000004000004200000000000000000000000000000000C5350000000000004800000002000500482300007011000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001B300400F20000000100001100281000000A0A0028020000060B731100000A0C086F1200000A1F18076F1300000A00086F1200000A1F0C72010000706F1300000A00281400000A0F00FE16130000016F1500000A6F1600000A0D08725D00007072D7000070096F1700000A26081204280300000613051105202C010000FE04130611062C3472E1000070281000000A1307120706281800000A13081208281900000A13091209281A00000A281B00000A281C00000A130ADE421205281D00000A72FF0000701104281E00000A281C00000A130ADE26130B00110B2804000006281C00000A130ADE13130C00110C6F1F00000A281C00000A130ADE00110A2A0000011C000000000700C2C900131700000100000700C2DC00131800000113300800CA0000000200001100120020B2070000171716161616282000000A281000000A13061206282100000A06282200000A0B1201282300000A282400000A20B0040000580C7205010070282500000A72450100701202282600000A281E00000A0D281400000A72490100706F1600000A732700000A13041104281400000A096F1600000A6F2800000A282900000A1305282A00000A72A30100701A8D1000000125167205010070282500000AA225171105282500000AA22518088C27000001A22519720B020070A2282B00000A13072B0011072A000013300300540000000300001100026F2C00000A723F0200701F246F2D00000A0A0614282E00000A0B072C2A0006026F2F00000A751B0000010C0814FE030D092C130003086F3000000A51086F3100000A13042B09000314511613042B0011042A1B3004007C0000000400001100026F1F00000A0A00026F3200000A741B0000010B076F3300000A0C733400000A0D08096F3500000A00096F3600000A1304281400000A11046F3700000A725B020070076F3100000A13051205FE161E0000016F1500000A727F020070283800000A0A00DE0E13060011066F1F00000A0A00DE000613072B0011072A01100000000008005E66000E180000012202283900000A002A00000042534A4201000100000000000C00000076342E302E33303331390000000005006C00000018040000237E000084040000E005000023537472696E677300000000640A00008402000023555300E80C0000100000002347554944000000F80C00007804000023426C6F620000000000000002000001571D02000900000000FA013300160000010000002D0000000200000004000000050000000400000039000000040000000F00000004000000010000000300000000000D0301000000000006001E02C60406008B02C60406003D016D040F00E60400000600650194030600010294030600CD01940306007202940306003E02940306005702940306007C01940306005101A70406002F01A7040600B001940306009701BB020600430546030A00EC014C040A0072004C040A00E402F5040600DC0046030E0061054A0506005B0346030E00BA034A050600D303460306000A00A90506000C0494030E001F014A05060036033F00060030033F000E009A004A050E00A6034A050E002A044A050600B2027A050600CD0046030600FA0246030600040046030600720546030E00D4054A0506000300460306004D03A90506001604700306003C0446030600F80046030600130594030E0023014A05000000001E000000000001000100010010002700000041000100010051803B006B02518081006B025180D4006B0251809E056B0250200000000096002E006E0201006C210000000091006403750202004422000000009100A90079020200A422000000009100C703810204003C23000000008618670406000500000001009605000001006B0502000200F303000001002204090067040100110067040600190067040A00290067041000310067041000390067041000410067041000490067041000510067041000590067041000610067041500690067041000710067041000790067041000890067040600A10086053200A90067040600A90020053700F9003D033C000901150044008100EE024A0009010A054E00A90055005400A1003A055D00B100910464001101EE024A0019012C056800990055056E002101EE024A0019012C057400C100C1004A00A10067048A00A100E5009500A10085039A00B1008004640029010100A3003101B700A8003901EE024A00C9006704AD0041010103B3002901D502BA004901FD00C00019013305C6008100F500DA0059016900E000D100C605E900D100A902F100D900DD034A00D9008B00F600B90012010C0169011E031201E90067040600E10005041701E9008E051D010901F702220119012C0528018100670406000E00040039010E000800A0010E000C00DF010E001000120220007B00BE032E000B0087022E00130090022E001B00AF022E002300B8022E002B00CA022E00330005032E003B0005032E004300B8022E004B000B032E00530005032E005B0005032E00630039032E006B0063032E00730070031A007B00D000FB000480000001000000000000000000000000002E0000000400000000000000000000003001600000000000040000000000000000000000300149000000000004000000000000000000000030014603000000000000000000546F55496E74333200484D4143534841323536006765745F55544638003C4D6F64756C653E00434C525544460053656E6453424D7367554446005552490053797374656D2E494F0053797374656D2E446174610055706C6F616444617461006D73636F726C6962004765744669656C6400446174614163636573734B696E64004E616D657370616365006765745F537461747573436F64650048747470537461747573436F646500476574537461747573436F64650055726C456E636F6465006765745F4D65737361676500446F75626C65004B65794E616D65004461746554696D6500546F556E6976657273616C54696D650047657454797065006765745F496E76617269616E7443756C74757265006765745F526573706F6E73650048747470576562526573706F6E736500477569644174747269627574650044656275676761626C6541747472696275746500436F6D56697369626C6541747472696275746500417373656D626C795469746C6541747472696275746500417373656D626C7954726164656D61726B417474726962757465005461726765744672616D65776F726B41747472696275746500417373656D626C7946696C6556657273696F6E41747472696275746500417373656D626C79436F6E66696775726174696F6E4174747269627574650053716C46756E6374696F6E41747472696275746500417373656D626C794465736372697074696F6E41747472696275746500436F6D70696C6174696F6E52656C61786174696F6E7341747472696275746500417373656D626C7950726F6475637441747472696275746500417373656D626C79436F7079726967687441747472696275746500417373656D626C79436F6D70616E794174747269627574650052756E74696D65436F6D7061746962696C6974794174747269627574650047657456616C756500456E636F64696E670053797374656D2E52756E74696D652E56657273696F6E696E6700546F426173653634537472696E670053716C537472696E6700546F537472696E6700476574537472696E6700436F6D70757465486173680053656E6453424D73675544462E646C6C00476574526573706F6E736553747265616D004D656D6F727953747265616D007365745F4974656D0053797374656D0048617368416C676F726974686D0054696D655370616E00476574536173546F6B656E0053797374656D2E476C6F62616C697A6174696F6E006F705F5375627472616374696F6E0053797374656D2E5265666C656374696F6E00576562486561646572436F6C6C656374696F6E00576562457863657074696F6E004765744572726F7246726F6D457863657074696F6E006765745F5374617475734465736372697074696F6E007374617475734465736372697074696F6E00436F7079546F004669656C64496E666F0043756C74757265496E666F00776562457863700048747470526571756573744865616465720049466F726D617450726F7669646572004D6963726F736F66742E53716C5365727665722E536572766572002E63746F720053797374656D2E446961676E6F7374696373006765745F546F74616C5365636F6E6473006765745F546F74616C4D696C6C697365636F6E64730053797374656D2E52756E74696D652E496E7465726F7053657276696365730053797374656D2E52756E74696D652E436F6D70696C6572536572766963657300446562756767696E674D6F6465730053797374656D2E446174612E53716C54797065730047657442797465730042696E64696E67466C616773006765745F4865616465727300436F6E63617400466F726D6174005375627472616374004F626A6563740053797374656D2E4E6574006F705F496D706C6963697400576562436C69656E7400636C69656E7400436F6E766572740053797374656D2E54657874006765745F4E6F7700546F4172726179006D7367626F6479004163636F756E744B65790053797374656D2E53656375726974792E43727970746F677261706879006F705F496E657175616C697479005765625574696C6974790000005B6100700070006C00690063006100740069006F006E002F00610074006F006D002B0078006D006C003B0074007900700065003D0065006E007400720079003B0063006800610072007300650074003D007500740066002D0038000179680074007400700073003A002F002F006D00760068007300620070006F0063002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E00650074002F007400610062006C0065006300680061006E00670065002F006D006500730073006100670065007300000950004F0053005400001D45006C00610070007300650064002000740069006D0065003A00200000053A002000003F6D00760068007300620070006F0063002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E006500740000030A00005970006A0055006C00750037006F0034006B00740053002F004C004A004E0043007A004A00390061007A004A0054006B0037006E003900500056002B00420045004A00450034006D007800530030007A0043006F0063003D0000675300680061007200650064004100630063006500730073005300690067006E00610074007500720065002000730072003D007B0030007D0026007300690067003D007B0031007D002600730065003D007B0032007D00260073006B006E003D007B0033007D00003352006F006F0074004D0061006E006100670065005300680061007200650064004100630063006500730073004B0065007900001B6D005F0057006500620052006500730070006F006E0073006500002320002800480074007400700053007400610074007500730043006F00640065002000000329000000B7AF652BFA2E854AB56B7B88CD8B267200042001010803200001052001011111042001010E042001010217070D11510E12551D050E0802115111590D114D125D12610400001151042000127D072002011180810E0500001280850320000E0520011D050E0820031D050E0E1D05062001115911510320000D0500020E0E0E050001114D0E0600030E0E0E0E0E070811511159090E12650E11510E0A200701080808080808080420001151080002115911511151040001090D0400010E0E052001011D050620011D051D050500010E1D050500001280A50900030E1280A90E1D1C090705126902126D02080520001280AD08200212690E1180B107000202126912690420011C1C04200011791007080E126D127112751D05117912610E0520001280B504200012710520010112710420001D050520010E1D050700040E0E0E0E0E08B77A5C561934E08966680074007400700073003A002F002F006D00760068007300620070006F0063002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E00650074002F007400610062006C0065006300680061006E00670065003E6D00760068007300620070006F0063002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E00650074003252006F006F0074004D0061006E006100670065005300680061007200650064004100630063006500730073004B00650079005870006A0055006C00750037006F0034006B00740053002F004C004A004E0043007A004A00390061007A004A0054006B0037006E003900500056002B00420045004A00450034006D007800530030007A0043006F0063003D0002060E060001114D114D0300000E070002081255100E0500010E125D0801000800000000001E01000100540216577261704E6F6E457863657074696F6E5468726F7773010801000701000000001101000C53656E6453424D736755444600003A010035504F43206F6620434C522055444620746F2073656E642061206D65737361676520746F20417A75726520536572766963652042757300000501000000002D010028436F7079726967687420C2A9202032303139204D6963726F736F667420436F72706F726174696F6E00002901002431386665333834642D306565652D343338642D613334632D37393661663831633539333900000C010007312E302E302E3000004D01001C2E4E45544672616D65776F726B2C56657273696F6E3D76342E372E320100540E144672616D65776F726B446973706C61794E616D65142E4E4554204672616D65776F726B20342E372E3280B601000300540E044E616D650C53656E6453424D73675544465455794D6963726F736F66742E53716C5365727665722E5365727665722E446174614163636573734B696E642C2053797374656D2E446174612C2056657273696F6E3D342E302E302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D623737613563353631393334653038390A446174614163636573730000000054020F497344657465726D696E69737469630000000000000033DF369D0000000002000000A1000000F0340000F01600000000000000000000000000001000000000000000000000000000000052534453066382C311C09A4CA3C2D2A414EB08C201000000433A5C55736572735C6D6976616E6875755C736F757263655C7265706F735C444D4A476974536F75726365436F6E74726F6C5C507269766174655C495020616E6420536372697074735C546F6F6C735C53514C53657276696365427573504F435C53656E6453424D73675544465C6F626A5C44656275675C53656E6453424D73675544462E70646200B93500000000000000000000D3350000002000000000000000000000000000000000000000000000C5350000000000000000000000005F436F72446C6C4D61696E006D73636F7265652E646C6C0000000000000000FF2500200010000000000000000000000000000000000000000000000000000000000000000000000100100000001800008000000000000000000000000000000100010000003000008000000000000000000000000000000100000000004800000058400000D00300000000000000000000D00334000000560053005F00560045005200530049004F004E005F0049004E0046004F0000000000BD04EFFE00000100000001000000000000000100000000003F000000000000000400000002000000000000000000000000000000440000000100560061007200460069006C00650049006E0066006F00000000002400040000005400720061006E0073006C006100740069006F006E00000000000000B00430030000010053007400720069006E006700460069006C00650049006E0066006F0000000C030000010030003000300030003000340062003000000084003600010043006F006D006D0065006E0074007300000050004F00430020006F006600200043004C0052002000550044004600200074006F002000730065006E0064002000610020006D00650073007300610067006500200074006F00200041007A00750072006500200053006500720076006900630065002000420075007300000022000100010043006F006D00700061006E0079004E0061006D006500000000000000000042000D000100460069006C0065004400650073006300720069007000740069006F006E0000000000530065006E006400530042004D007300670055004400460000000000300008000100460069006C006500560065007200730069006F006E000000000031002E0030002E0030002E003000000042001100010049006E007400650072006E0061006C004E0061006D0065000000530065006E006400530042004D00730067005500440046002E0064006C006C00000000007400280001004C006500670061006C0043006F007000790072006900670068007400000043006F0070007900720069006700680074002000A90020002000320030003100390020004D006900630072006F0073006F0066007400200043006F00720070006F0072006100740069006F006E0000002A00010001004C006500670061006C00540072006100640065006D00610072006B00730000000000000000004A00110001004F0072006900670069006E0061006C00460069006C0065006E0061006D0065000000530065006E006400530042004D00730067005500440046002E0064006C006C00000000003A000D000100500072006F0064007500630074004E0061006D00650000000000530065006E006400530042004D007300670055004400460000000000340008000100500072006F006400750063007400560065007200730069006F006E00000031002E0030002E0030002E003000000038000800010041007300730065006D0062006C0079002000560065007200730069006F006E00000031002E0030002E0030002E003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000C000000E83500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C005000000020200308205B106092A864886F70D010702A08205A23082059E020101310B300906052B0E03021A0500304C060A2B060104018237020104A03E303C3017060A2B06010401823702010F3009030100A004A20280003021300906052B0E03021A05000414F6B54A3E6A4D0C59CFD69D268DE130640D74238AA082036E3082036A30820256A00302010202106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021D0500303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C5220436572743020170D3139303930343230333432385A180F32303939313233313034303030305A303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C52204365727430820122300D06092A864886F70D01010105000382010F003082010A0282010100BFA0F1A347A83B886B753FA158B65426B1DEECB2C46A9660135BDA45F56F8714800C515BE1609962B57A575E5A4339683CE1665C0E2E3812F6F6958EF96FE97893BD778D4230516005FE682CF5C263E6638A45B21F8F15CC07927B7937796E56591B1D706DF6726D84C646027C5FF28D2B567627A72E0DA6DDF41808D0DF9281E47E9C8AE007CF4DBAD4E349179A1C9FC3E9DD62EC9C448E9CFD3AA9E2DAE3DB9E86A028CFA1C24885C7DFA45FA9C8B35A98ED2EF31A3F5DDD30E03B6E64B1F135BAFA1FAB08199DD5DFAE0F894544100B91AECB117101DAA49E526A309B6915DD822C0285B24F3CFA2BF89088984E21B6674C2B1692B395985C0B51D9EF07D90203010001A370306E306C0603551D01046530638010F4A197D3F4E3ECF1D4E1E0417E935184A13D303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C52204365727482106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021D05000382010100853E32A6278392ECF28EABD5EB9F2297D3282949818DD9CF4E175AB32D9588B2B144A920D630788E10CBF66DF0A135E43FCD36892F1E779D6D9EEA3CDC417C480D9A95257313C79678235019A419DF1F61E085D5B23CADDEDA108B16DF4C6C31658D56816A85424D90F6F715C271C9A6A642CE987841B31F41CFB2522CAC23C3D69DC6B9D8F5ED237E756425BBE288ADF80F1BE6971A7A0CA3BE442461B17DA9DF975798B1642F1686DD962DDAF341C76697A98E403F812311AA0B146580E458C9301E7BE02E2D33511F2461591A6FD163F8E78AD80E79B58B9D5F7CBBE386DE0F7E610A305777FB35BD1B6C4F55CCD11A5E9F04C5558DA24A62BEDBE98A7EE3318201CA308201C6020101304F303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C52204365727402106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021A0500A0523010060A2B06010401823702010C31023000301906092A864886F70D010903310C060A2B060104018237020104302306092A864886F70D010904311604140372231A9DFC582617A3B13225BDB3D1934A9432300D06092A864886F70D01010105000482010022D6019153C67E95850937BBDF44E030123F2F78422DB9E1AD8C22C1431620C3BCAFC1015EA4096BF9E6808D905721E35F89064D970AFBDD021ACD46DA18BFD76904E454BC2A6CE365885CEB781AA35A68F0E98BBC78A70919F032BE07EBCD779560FE886F96A4C81C98520290976B5CD2844C937779BD55246D942BEF57A07E3F3B81C1895D4E602A9660B4CF45976C5A6D898E93E29C0DAAFB66355BCC13D6FE9CC380D1FA91421DDDFFAECF8ACE007A7A037223C93D7820BF00A73256399CBA0377C85C80D3E99734388794C13DCEDD97B7415668D68AD59E6DADD562AFF3E49BB66683E3ECC2FB131A344D144E4394F64E105E19BA6B530B68D0309ACD50000000
+WITH PERMISSION_SET = UNSAFE
+GO
+CREATE TRIGGER testclr_SO
+ON Sales.Orders
+FOR INSERT, UPDATE, DELETE
+AS
+EXTERNAL NAME SendSBMsg.CLRTriggers.trgSendSBMsg;
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to Service Broker to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 1 and 100
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 11 and 1011
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 21 and 30
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 31 and 40
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 41 and 50
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 51 and 60
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 61 and 70
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 71 and 80
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 81 and 90
+go
+update Sales.Orders set Comments='Service Bus to Activation Proc to CLR UDF - update in MI', PerfTest=sysdatetime() where OrderID between 91 and 100
+go
+
+
+DROP Function SendSBMsg
+go
+CREATE FUNCTION SendSBMsg(@msgbody nvarchar(max))
+RETURNS nvarchar(max)
+AS
+EXTERNAL NAME SendSBMsgUDF.CLRUDF.SendSBMsgUDF;
+go
+
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- DIRECT SEND TO SERVICE BUS TRIGGER
+drop trigger sales.trgsenddirect_SO
+go
+create trigger trgsenddirect_SO on Sales.Orders
+for insert, update, delete
+as
+declare @inserted int
+select @inserted=count(*) from inserted
+declare @msgbody nvarchar(max)
+if (@inserted > 0)
+ begin
+ set @msgbody = (select * from inserted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'insert' + @msgbody + ''
+ end
+else
+ begin
+ set @msgbody = (select * from deleted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'delete' + @msgbody + ''
+ end
+select dbo.SendSBMsg(@msgbody)
+go
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/.gitignore b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/.gitignore
new file mode 100644
index 0000000..ff5b00c
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/.gitignore
@@ -0,0 +1,264 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# Azure Functions localsettings file
+local.settings.json
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+#*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/Message.cs b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/Message.cs
new file mode 100644
index 0000000..07d9347
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/Message.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+
+namespace SBMsgFnApp
+{
+ public class column
+ {
+ public string colname { get; set; }
+ public string value { get; set; }
+ public bool IsPK { get; set; }
+ public bool NeedsQuote { get; set; }
+ }
+
+ public class row
+ {
+ public List columns { get; set; }
+
+ public row()
+ {
+ columns = new List();
+ }
+ }
+
+ public class message
+ {
+ public string server { get; set; }
+ public string action { get; set; }
+ public string table { get; set; }
+ public List rows { get; set; }
+ }
+}
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/MsgProcessorFn.cs b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/MsgProcessorFn.cs
new file mode 100644
index 0000000..e798c8f
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/MsgProcessorFn.cs
@@ -0,0 +1,252 @@
+using System;
+using Microsoft.Azure.WebJobs;
+using Microsoft.Azure.WebJobs.Host;
+using Microsoft.Extensions.Logging;
+using System.Xml;
+using System.Xml.Serialization;
+using System.IO;
+using System.Data.SqlClient;
+using System.Reflection.Emit;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Collections;
+
+/*
+Title: SendSBMsg
+Author: Mitch van Huuksloot,
+ Data Migration Jumpstart Team
+Copyright © 2019 Microsoft Corporation
+
+The Sample Code below was developed by Microsoft Corporation technical architects. Because Microsoft must respond to changing market conditions, this document should not be interpreted as an invitation to contract or a commitment on the part of Microsoft.
+Microsoft has provided high level guidance in this artifact with the understanding that the reader would undertake detailed design and comprehensive reviews of the overall solution before the solution would be implemented/delivered.
+Microsoft is not responsible for the final implementation undertaken.
+MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED WITH RESPECT TO THE INFORMATION CONTAINED HEREIN.
+*/
+
+
+namespace SBMsgFnApp
+{
+ public class ColInfo
+ {
+ public string ColName { get; set; }
+ public int NeedsQuote { get; set; }
+ }
+
+ public static class MsgProcessorFn
+ {
+ private const string PKQuery = "select '[' + s.[name] + '].[' + o.[name] + ']', c.[name] " +
+ "from sys.index_columns ic join sys.indexes i on (ic.object_id=i.object_id and ic.index_id=i.index_id) " +
+ "join sys.columns c on (c.object_id=ic.object_id and ic.column_id=c.column_id) " +
+ "join sys.objects o on(ic.object_id= o.object_id) " +
+ "join sys.schemas s on (o.schema_id= s.schema_id) " +
+ "where i.is_primary_key=1 and ic.object_id=object_id('%') order by ic.key_ordinal";
+ private const string ColQuey = "select [name], CAST(CASE WHEN system_type_id in (48,52,56,59,60,62,106,108,122,127) then 0 else 1 end as int) from sys.columns where object_id=object_id('%') and is_computed=0 order by column_id";
+ private static List colinf = new List();
+
+ private static int NeedsQuote(string colname)
+ {
+ foreach (ColInfo c in colinf)
+ {
+ if (colname == c.ColName) return c.NeedsQuote;
+ }
+ return -1;
+ }
+
+ [FunctionName("MsgProcessorFn")]
+ public static void Run([ServiceBusTrigger("tablechange", "msgprocessor", Connection = "SBCon")]string SbMsg, ILogger log)
+ {
+#if DEBUG
+ DateTime start = DateTime.Now;
+#endif
+ string[] pks = new string[32];
+ int pk = 0;
+
+#if DEBUG
+ log.LogInformation($"C# ServiceBus topic trigger function processed message: {SbMsg}");
+#endif
+ try
+ {
+ // there is an issue deserializing the XML message since FOR XML PATH used column names as the XML tags around the values
+ // therefore the code needs to intercept deserialization exceptions and create the appropriate columns list items
+ XmlSerializer xs = new XmlSerializer(typeof(message));
+ xs.UnknownElement += xs_UnknownElement; // add event handler to handle deserialization issues
+ StringReader srdr = new StringReader(SbMsg);
+ message msg = (message)xs.Deserialize(srdr); // deserialize into message structure
+#if DEBUG
+ log.LogInformation($"Server: {msg.server} Action: {msg.action} Table: {msg.table}"); // log what we now know
+#endif
+
+ string conStr = System.Environment.GetEnvironmentVariable($"ConnectionStrings:SQLCon", EnvironmentVariableTarget.Process);
+ if (string.IsNullOrEmpty(conStr)) // Azure Functions App Service naming convention
+ conStr = System.Environment.GetEnvironmentVariable($"SQLAZURECONNSTR_SQLCon", EnvironmentVariableTarget.Process);
+ string table = null;
+ using (SqlConnection con = new SqlConnection(conStr))
+ {
+ con.Open();
+ // get primary key columns
+ using (SqlCommand cmd = new SqlCommand(PKQuery.Replace("%", msg.table), con))
+ {
+ using (SqlDataReader rdr = cmd.ExecuteReader(System.Data.CommandBehavior.SingleResult))
+ {
+ while (rdr.Read())
+ {
+ if (table == null) table = rdr.GetString(0);
+ pks[pk++] = rdr.GetString(1);
+ }
+ rdr.Close();
+ }
+ }
+ // get a list of all columns and data types
+ using (SqlCommand cmd = new SqlCommand(ColQuey.Replace("%", msg.table), con))
+ {
+ using (SqlDataReader rdr = cmd.ExecuteReader(System.Data.CommandBehavior.SingleResult))
+ {
+ while (rdr.Read()) colinf.Add(new ColInfo() { ColName = rdr.GetString(0), NeedsQuote = rdr.GetInt32(1) });
+ rdr.Close();
+ }
+ }
+ // if insert - might be an insert or an update - go generate a conditional insert/update
+ if (msg.action == "insert")
+ {
+ // build and execute an upsert
+ foreach (row r in msg.rows)
+ {
+ string sqlstmt = "if exists (select 1 from " + table + " where ";
+ string pkwhere = "";
+ for (int i = 0; i < pk; i++)
+ {
+ foreach (column c in r.columns)
+ {
+ if (NeedsQuote(pks[i]) == 1) c.NeedsQuote = true; // not checking if it is computed column
+ if (i > 0) pkwhere += " and ";
+ if (c.colname == pks[i])
+ {
+ pkwhere += pks[i] + "=";
+ if (c.NeedsQuote) pkwhere += "'";
+ pkwhere += c.value;
+ if (c.NeedsQuote) pkwhere += "'";
+ c.IsPK = true;
+ }
+ }
+ }
+ sqlstmt += pkwhere + ")\nupdate " + table + " set ";
+ string update = "";
+ string insertcol = "";
+ string insertval = "";
+ foreach (column c in r.columns)
+ {
+ int nq = NeedsQuote(c.colname);
+ if (nq == 1) c.NeedsQuote = true;
+ if (nq != -1) // filter out computed columns - which won't show up in column list (explicitly filtered out)
+ {
+ if (update != "") update += ",";
+ if (insertcol != "")
+ {
+ insertcol += ",";
+ insertval += ",";
+ }
+ if (!c.IsPK)
+ {
+ if (c.colname == "PerfTest") update += c.colname + "=sysdatetime()"; // special column for performance testing? Update time to current time.
+ else
+ {
+ update += c.colname + "=";
+ if (c.NeedsQuote) update += "'";
+ update += c.value;
+ if (c.NeedsQuote) update += "'";
+ }
+ }
+ insertcol += c.colname;
+ if (c.NeedsQuote) insertval += "'";
+ insertval += c.value;
+ if (c.NeedsQuote) insertval += "'";
+ }
+ }
+ sqlstmt += update + " where " + pkwhere + "\nelse\ninsert into " + table + " (" + insertcol + ") values (" + insertval + ")";
+#if DEBUG
+ log.LogInformation($"SQL Upsert: {sqlstmt}");
+#endif
+ using (SqlCommand cmd = new SqlCommand(sqlstmt, con))
+ {
+ cmd.ExecuteNonQuery();
+ }
+ }
+ }
+ // if delete - then generate delete statement (we don't get a delete on an update)
+ else if (msg.action == "delete")
+ {
+ foreach (row r in msg.rows)
+ {
+ string sqlwhere = "";
+ if (pk > 0) // does the table have a primary key?
+ {
+ for (int i = 0; i < pk; i++)
+ {
+ foreach (column c in r.columns)
+ {
+ if (i > 0) sqlwhere += " and ";
+ if (NeedsQuote(c.colname) == 1) c.NeedsQuote = true;
+ if (c.colname == pks[i])
+ {
+ sqlwhere += pks[i] + "=";
+ if (c.NeedsQuote) sqlwhere += "'";
+ sqlwhere += c.value;
+ if (c.NeedsQuote) sqlwhere += "'";
+ }
+ }
+ }
+ }
+ else // no primary key - use all columns/values in where clause
+ {
+ foreach (column c in r.columns)
+ {
+ int nq = NeedsQuote(c.colname);
+ if (nq == 1) c.NeedsQuote = true;
+ if (nq != -1) // filter out computed columns - which won't show up in column list (explicitly filtered out)
+ {
+ if (sqlwhere.Length == 0) sqlwhere += " and ";
+ sqlwhere += c.colname + "=";
+ if (c.NeedsQuote) sqlwhere += "'";
+ sqlwhere += c.value;
+ if (c.NeedsQuote) sqlwhere += "'";
+ }
+ }
+ }
+ string sqlstmt = "delete from " + table + " where " + sqlwhere;
+#if DEBUG
+ log.LogInformation($"SQL Delete: {sqlstmt}");
+#endif
+ using (SqlCommand cmd = new SqlCommand(sqlstmt, con))
+ {
+ cmd.ExecuteNonQuery();
+ }
+ }
+ }
+ con.Close();
+ }
+ }
+ catch (Exception e)
+ {
+ log.LogError($"Exception: {e.Message}");
+ log.LogError($"Exception Stack: {e.StackTrace}");
+ }
+#if DEBUG
+ log.LogInformation($"Duration (ms): {DateTime.Now.Subtract(start).TotalMilliseconds.ToString()}");
+#endif
+ }
+
+ private static void xs_UnknownElement(object sender, XmlElementEventArgs e)
+ {
+ if (e.ObjectBeingDeserialized.GetType() == typeof(row))
+ {
+ row currow = (row)e.ObjectBeingDeserialized;
+ foreach (XmlNode node in e.Element.ChildNodes)
+ {
+ if (currow.columns == null) currow.columns = new List();
+ currow.columns.Add(new column() { colname = node.ParentNode.Name, value = node.InnerText, IsPK = false, NeedsQuote = false });
+ }
+ }
+ }
+ }
+}
+
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/ProcessTableChange.csproj b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/ProcessTableChange.csproj
new file mode 100644
index 0000000..db21be5
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/ProcessTableChange.csproj
@@ -0,0 +1,32 @@
+
+
+ netcoreapp2.1
+ v2
+
+
+ DEBUG;TRACE
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+ Never
+
+
+
+
+ Always
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/ProcessTableChange.sln b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/ProcessTableChange.sln
new file mode 100644
index 0000000..799d098
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/ProcessTableChange.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29306.81
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessTableChange", "ProcessTableChange.csproj", "{6196D1EA-FF35-4BFE-A158-5FAB092D4DD7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6196D1EA-FF35-4BFE-A158-5FAB092D4DD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6196D1EA-FF35-4BFE-A158-5FAB092D4DD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6196D1EA-FF35-4BFE-A158-5FAB092D4DD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6196D1EA-FF35-4BFE-A158-5FAB092D4DD7}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {BAEE6BD3-DC1B-44A2-B170-AC89AFA9FC73}
+ EndGlobalSection
+EndGlobal
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/host.json b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/host.json
new file mode 100644
index 0000000..b9f92c0
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/ProcessTableChange/host.json
@@ -0,0 +1,3 @@
+{
+ "version": "2.0"
+}
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/CLRTrigger.cs b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/CLRTrigger.cs
new file mode 100644
index 0000000..f218883
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/CLRTrigger.cs
@@ -0,0 +1,227 @@
+using System;
+using System.Data;
+using Microsoft.SqlServer.Server;
+using System.Data.SqlTypes;
+using System.Data.SqlClient;
+using System.Text;
+using System.IO;
+using System.Net;
+using System.Security.Cryptography;
+using System.Globalization;
+using System.Reflection;
+using System.Threading;
+using System.ComponentModel.Design;
+
+/*
+Title: SendSBMsg
+Author: Mitch van Huuksloot,
+ Data Migration Jumpstart Team
+
+The Sample Code below was developed by Microsoft Corporation technical architects. Because Microsoft must respond to changing market conditions, this document should not be interpreted as an invitation to contract or a commitment on the part of Microsoft.
+Microsoft has provided high level guidance in this artifact with the understanding that the reader would undertake detailed design and comprehensive reviews of the overall solution before the solution would be implemented/delivered.
+Microsoft is not responsible for the final implementation undertaken.
+MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED WITH RESPECT TO THE INFORMATION CONTAINED HEREIN.
+*/
+
+public class CLRTriggers
+{
+ private const string URI = "https://mvhsbpoc.servicebus.windows.net/tablechange";
+ private const string Namespace = "mvhsbpoc.servicebus.windows.net";
+ private const string KeyName = "RootManageSharedAccessKey";
+ private const string AccountKey = "5VHeguGPSAKbd5fROzPbYjGsMeo5FiFGLNT6Pbfan2X=";
+ private const string hashqry = "WITH cols as ( "+
+ "select top 100000 c.object_id, column_id, c.[name] "+
+ "from sys.columns c "+
+ "JOIN sys.objects ot on (c.object_id= ot.parent_object_id and ot.type= 'TA') " +
+ "order by c.object_id, column_id ) "+
+ "SELECT s.[name] + '.' + o.[name] as 'TableName', CONVERT(NCHAR(32), HASHBYTES('MD5',STRING_AGG(CONVERT(NCHAR(32), HASHBYTES('MD5', cols.[name]), 2), '|')),2) as 'MD5Hash' " +
+ "FROM cols "+
+ "JOIN sys.objects o on (cols.object_id= o.object_id) "+
+ "JOIN sys.schemas s on (o.schema_id= s.schema_id) "+
+ "WHERE o.is_ms_shipped = 0 "+
+ "GROUP BY s.[name], o.[name]";
+
+ // [SqlTrigger(Name = @"SendSBMsg", Target = "[dbo].[table]", Event = "FOR INSERT, UPDATE")]
+ public static void trgSendSBMsg()
+ {
+#if DEBUG
+ DateTime start = DateTime.Now;
+#endif
+ string table = "", server = "", msgbody;
+ SqlCommand cmd;
+ SqlDataReader rdr;
+ SqlTriggerContext trigContxt = SqlContext.TriggerContext;
+ SqlPipe p = SqlContext.Pipe;
+
+ using (SqlConnection con = new SqlConnection("context connection=true"))
+ {
+ // build message to send - we match the XML generated by the TSQL DML triggers (i.e. "FOR XML PATH" format - although we could easily produce an easier XML string to parse at the other end).
+ try
+ {
+ con.Open();
+
+ // We need to get the table name somehow, since it is not in either the SqlContext or the SqlTriggerContext :-(
+ // One work around is to look at the table your session has locked, but we think that is fragile - think transactions on multiple tables or holdlock etc.
+ // We use a somewhat expensive work around that uses an MD5 hash of the column names from the inserted or deleted tables and compares it to the column name hashes of tables in the current database with CLR triggers.
+ // For efficiency, the code to calculate the hashes is embedded in the rest of the trigger processing.
+ // In theory we could also look at the plan of the currently executing statement and pull the table from that, but that is likely much more overhead.
+
+ MD5 hash = MD5.Create();
+ StringBuilder hashstr = new StringBuilder(250);
+ string sqlcmd, tblhash = "", rows = "";
+ if (trigContxt.TriggerAction == TriggerAction.Delete)
+ {
+ sqlcmd = "SELECT * FROM DELETED";
+ msgbody = "" + server + "delete";
+ }
+ else // insert or update - the target figures out which is necessary
+ {
+ sqlcmd = "SELECT * FROM INSERTED";
+ msgbody = "" + server + "insert";
+ }
+ using (cmd = new SqlCommand(sqlcmd, con))
+ {
+ using (rdr = cmd.ExecuteReader(CommandBehavior.SingleResult))
+ {
+ while (rdr.Read())
+ {
+ rows += "";
+ for (int i = 0; i < rdr.FieldCount; i++)
+ {
+ string colname = rdr.GetName(i);
+ if (tblhash.Length == 0) // only calculate the column name hash for the first record
+ {
+ if (i > 0) hashstr.Append("|"); // use a pipe separator
+ hashstr.Append(GetMD5Hash(hash, colname)); // append the hash to the hash string
+ }
+ rows += "<" + colname + ">" + rdr.GetValue(i).ToString() + "" + colname + ">";
+ }
+ rows += "
";
+ if (tblhash.Length == 0) tblhash = GetMD5Hash(hash, hashstr.ToString().ToUpper()).ToUpper(); // hash the hash string to reduce the string size to 32 characters
+ }
+ }
+ rdr.Close();
+ }
+ using (cmd = new SqlCommand(hashqry, con))
+ {
+ using (rdr = cmd.ExecuteReader(CommandBehavior.SingleResult)) // get the hashes for all tables with CLR triggers
+ {
+ while (rdr.Read())
+ {
+ string shash = rdr.GetString(1).ToUpper(); // get the hash string from sql
+ if (shash == tblhash) // if it matches, we have our table
+ {
+ table = rdr.GetString(0); // get the table name
+ break;
+ }
+ }
+ rdr.Close();
+ }
+ }
+ if (table.Length == 0)
+ {
+ p.Send("Error: Unable to find table that CLR trigger is on. Message not sent!");
+ return;
+ }
+ msgbody += table + rows + "";
+ }
+ catch (Exception e)
+ {
+ p.Send("Exception: " + e.Message);
+ return;
+ }
+ con.Close();
+#if DEBUG
+ p.Send("Message: " + msgbody.Substring(0,3500));
+ p.Send("Elapsed Time (ms): " + DateTime.Now.Subtract(start).TotalMilliseconds.ToString());
+#endif
+ }
+
+ //send message to Service Bus
+ try
+ {
+ string sasToken = GetSasToken();
+ WebClient webClient = new WebClient();
+ webClient.Headers[HttpRequestHeader.Authorization] = sasToken;
+ webClient.Headers[HttpRequestHeader.ContentType] = "application/atom+xml;type=entry;charset=utf-8";
+ var body = Encoding.UTF8.GetBytes(msgbody);
+ webClient.UploadData(URI + "/messages", "POST", body);
+ string httpmsg;
+ int status = GetStatusCode(webClient, out httpmsg);
+ if (status > 299) p.Send(status.ToString() + ": " + httpmsg);
+ }
+ catch (WebException ex)
+ {
+ p.Send("Web Exception: " + GetErrorFromException(ex));
+ }
+ catch (Exception ex)
+ {
+ p.Send("Exception: " + ex.Message);
+ }
+ }
+
+ private static string GetMD5Hash(MD5 md5Hash, string input)
+ {
+ byte[] data = md5Hash.ComputeHash(Encoding.Unicode.GetBytes(input));
+ StringBuilder sBuilder = new StringBuilder();
+ for (int i = 0; i < data.Length; i++)
+ sBuilder.Append(data[i].ToString("x2"));
+ return sBuilder.ToString();
+ }
+
+ // The following functions were borrowed from Jensen Somers - https://jsomers.be/archive/2018/12/20/sending-messages-to-azure-from-sql-server-part-1/
+ private static string GetSasToken()
+ {
+ // Set token lifetime to 20 minutes.
+ DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
+ TimeSpan diff = DateTime.Now.ToUniversalTime() - origin;
+ uint tokenExpirationTime = Convert.ToUInt32(diff.TotalSeconds) + (20 * 60);
+ string stringToSign = WebUtility.UrlEncode(Namespace) + "\n" + tokenExpirationTime.ToString();
+ var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(AccountKey));
+ var signature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(stringToSign)));
+ return string.Format(CultureInfo.InvariantCulture, "SharedAccessSignature sr={0}&sig={1}&se={2}&skn={3}", WebUtility.UrlEncode(Namespace), WebUtility.UrlEncode(signature), tokenExpirationTime, KeyName);
+ }
+
+ private static int GetStatusCode(WebClient client, out string statusDescription)
+ {
+ FieldInfo responseField = client.GetType().GetField("m_WebResponse", BindingFlags.Instance | BindingFlags.NonPublic);
+ if (responseField != null)
+ {
+ HttpWebResponse response = responseField.GetValue(client) as HttpWebResponse;
+ if (response != null)
+ {
+ statusDescription = response.StatusDescription;
+ return (int)response.StatusCode;
+ }
+ }
+ statusDescription = null;
+ return 0;
+ }
+
+ private static string GetErrorFromException(WebException webExcp)
+ {
+ var exceptionMessage = webExcp.Message;
+
+ try
+ {
+ var httpResponse = (HttpWebResponse)webExcp.Response;
+ var stream = httpResponse.GetResponseStream();
+ var memoryStream = new MemoryStream();
+
+ stream.CopyTo(memoryStream);
+
+ var receivedBytes = memoryStream.ToArray();
+ exceptionMessage = Encoding.UTF8.GetString(receivedBytes)
+ + " (HttpStatusCode "
+ + httpResponse.StatusCode.ToString()
+ + ")";
+ }
+ catch (Exception ex)
+ {
+ exceptionMessage = ex.Message;
+ }
+
+ return exceptionMessage;
+ }
+
+}
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/Configure SQL MI for CLR Trigger.sql b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/Configure SQL MI for CLR Trigger.sql
new file mode 100644
index 0000000..fc3348c
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/Configure SQL MI for CLR Trigger.sql
@@ -0,0 +1,45 @@
+use master
+go
+CREATE CERTIFICATE [SQLCLR-Cert]
+FROM BINARY = 0x3082036A30820256A00302010202106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021D\
+0500303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F\
+6D311430120603550403130B53514C434C5220436572743020170D3139303930343230333432385A\
+180F32303939313233313034303030305A303B310B30090603550406130255533116301406035504\
+0A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C5220436572743082\
+0122300D06092A864886F70D01010105000382010F003082010A0282010100BFA0F1A347A83B886B\
+753FA158B65426B1DEECB2C46A9660135BDA45F56F8714800C515BE1609962B57A575E5A4339683C\
+E1665C0E2E3812F6F6958EF96FE97893BD778D4230516005FE682CF5C263E6638A45B21F8F15CC07\
+927B7937796E56591B1D706DF6726D84C646027C5FF28D2B567627A72E0DA6DDF41808D0DF9281E4\
+7E9C8AE007CF4DBAD4E349179A1C9FC3E9DD62EC9C448E9CFD3AA9E2DAE3DB9E86A028CFA1C24885\
+C7DFA45FA9C8B35A98ED2EF31A3F5DDD30E03B6E64B1F135BAFA1FAB08199DD5DFAE0F894544100B\
+91AECB117101DAA49E526A309B6915DD822C0285B24F3CFA2BF89088984E21B6674C2B1692B39598\
+5C0B51D9EF07D90203010001A370306E306C0603551D01046530638010F4A197D3F4E3ECF1D4E1E0\
+417E935184A13D303B310B300906035504061302555331163014060355040A130D6D6963726F736F\
+66742E636F6D311430120603550403130B53514C434C52204365727482106DFC260EB312E79845D7\
+F0B3CC0E5088300906052B0E03021D05000382010100853E32A6278392ECF28EABD5EB9F2297D328\
+2949818DD9CF4E175AB32D9588B2B144A920D630788E10CBF66DF0A135E43FCD36892F1E779D6D9E\
+EA3CDC417C480D9A95257313C79678235019A419DF1F61E085D5B23CADDEDA108B16DF4C6C31658D\
+56816A85424D90F6F715C271C9A6A642CE987841B31F41CFB2522CAC23C3D69DC6B9D8F5ED237E75\
+6425BBE288ADF80F1BE6971A7A0CA3BE442461B17DA9DF975798B1642F1686DD962DDAF341C76697\
+A98E403F812311AA0B146580E458C9301E7BE02E2D33511F2461591A6FD163F8E78AD80E79B58B9D\
+5F7CBBE386DE0F7E610A305777FB35BD1B6C4F55CCD11A5E9F04C5558DA24A62BEDBE98A7EE3;
+GO
+CREATE LOGIN [SQLCLR-Login]
+FROM CERTIFICATE [SQLCLR-Cert];
+GO
+GRANT UNSAFE ASSEMBLY TO [SQLCLR-Login];
+GO
+USE MVHTest
+/* Object: SqlAssembly [SendSBMsg] - scripted by SSMS */
+CREATE ASSEMBLY [SendSBMsg]
+FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C010300C9F7698C0000000000000000E00022200B0130000024000000060000000000005643000000200000006000000000001000200000000200000400000000000000060000000000000000A0000000020000096B0000030060850000100000100000000010000010000000000000100000000000000000000000014300004F00000000600000780300000000000000000000002C0000C0050000008000000C00000070420000380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E746578740000005C230000002000000024000000020000000000000000000000000000200000602E7273726300000078030000006000000004000000260000000000000000000000000000400000402E72656C6F6300000C0000000080000000020000002A0000000000000000000000000000400000420000000000000000000000000000000035430000000000004800000002000500AC280000C419000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001B3005003E050000010000110072010000700B72030000700C140D280F00000A1306281000000A13077217000070731100000A1308000011086F1200000A0072470000701108731300000A25130413090011046F1400000AA5250000010A00DE0D11092C0811096F1500000A00DC7258010070729B0300701200281600000A281700000A1108731300000A251304130A001104176F1800000A251305130B002B7F00077201000070281900000A130C110C2C1D001105166F1A00000A0B08729F0300700772AF030070281B00000A0C001105176F1C00000A16FE01130D110D2C3E001105176F1A00000A130E0872C1030070110E72CB030070281B00000A0C0914FE03130F110F2C0C0972D7030070281D00000A0D09110E281D00000A0D000011056F1E00000A131011103A71FFFFFF11056F1F00000A0000DE0D110B2C08110B6F1500000A00DC00DE0D110A2C08110A6F1500000A00DC11066F2000000A13121112131111111759450300000005000000F4000000E301000038CA0200000872DB030070281D00000A0C720B0400701108731300000A2513041313001104176F1800000A251305131400388100000000087239040070281D00000A0C1613152B5100110511156F2100000A13161C8D27000001251608A225177245040070A225181116A225197263040070A2251A110511156F2200000A6F2300000AA2251B7269040070A2282400000A0C00111517581315111511056F2500000AFE04131711172D9E08727D040070281D00000A0C0011056F1E00000A131811183A6FFFFFFF11056F1F00000A0000DE0D11142C0811146F1500000A00DC00DE0D11132C0811136F1500000A00DC38DB01000008728B040070281D00000A0C720B0400701108731300000A2513041319001104176F1800000A251305131A00388100000000087239040070281D00000A0C16131B2B51001105111B6F2100000A131C1C8D27000001251608A225177245040070A22518111CA225197263040070A2251A1105111B6F2200000A6F2300000AA2251B7269040070A2282400000A0C00111B1758131B111B11056F2500000AFE04131D111D2D9E08727D040070281D00000A0C0011056F1E00000A131E111E3A6FFFFFFF00DE0D111A2C08111A6F1500000A00DC11056F1F00000A0000DE0D11192C0811196F1500000A00DC38EC0000000872BB040070281D00000A0C72EB0400701108731300000A251304131F001104176F1800000A251305132000388100000000087239040070281D00000A0C1613212B5100110511216F2100000A13221C8D27000001251608A225177245040070A225181122A225197263040070A2251A110511216F2200000A6F2300000AA2251B7269040070A2282400000A0C00112117581321112111056F2500000AFE04132311232D9E08727D040070281D00000A0C0011056F1E00000A132411243A6FFFFFFF11056F1F00000A0000DE0D11202C0811206F1500000A00DC00DE0D111F2C08111F6F1500000A00DC2B00087217050070281D00000A0C00DE211325001107722D05007011256F2600000A281D00000A6F2700000A00DDD000000011086F2800000A0000DE0D11082C0811086F1500000A00DC000028020000061326732900000A132711276F2A00000A1F1811266F2B00000A0011276F2A00000A1F0C72450500706F2B00000A00282C00000A086F2D00000A1328112772A1050070722106007011286F2E00000A26112712292803000006132A112A202B010000FE02132B112B2C1B1107122A281600000A722B0600701129282F00000A6F2700000A0000DE2A132C001107112C28040000066F2700000A0000DE15132D001107112D6F2600000A6F2700000A0000DE002A0000413C0100020000004400000011000000550000000D0000000000000002000000920000009D0000002F0100000D000000000000000200000084000000BB0000003F0100000D00000000000000020000009E010000A2000000400200000D000000000000000200000090010000C0000000500200000D00000000000000020000008D0200009A000000270300000D00000000000000020000007F020000C00000003F0300000D00000000000000020000007C030000A20000001E0400000D00000000000000020000006E030000C00000002E0400000D00000000000000000000002A000000220400004C040000210000001700000102000000290000004F040000780400000D0000000000000000000000860400008D00000013050000150000001900000100000000860400008D00000028050000150000001700000113300800CA0000000200001100120020B2070000171716161616283000000A283100000A13061206283200000A06283300000A0B1201283400000A283500000A20B0040000580C7231060070283600000A727B0600701202283700000A282F00000A0D282C00000A727F0600706F2D00000A733800000A13041104282C00000A096F2D00000A6F3900000A283A00000A1305283B00000A72D90600701A8D1000000125167231060070283600000AA225171105283600000AA22518088C2F000001A225197241070070A2283C00000A13072B0011072A000013300300540000000300001100026F3D00000A72750700701F246F3E00000A0A0614283F00000A0B072C2A0006026F4000000A751E0000010C0814FE030D092C130003086F4100000A51086F4200000A13042B09000314511613042B0011042A1B300400730000000400001100026F2600000A0A00026F4300000A741E0000010B076F4400000A0C734500000A0D08096F4600000A00096F4700000A1304282C00000A11046F4800000A7291070070076F4200000A13051205FE16210000016F2300000A72B5070070281B00000A0A00DE05260000DE000613062B0011062A0001100000000008005E660005170000012202284900000A002A00000042534A4201000100000000000C00000076342E302E33303331390000000005006C000000A8040000237E000014050000BC06000023537472696E677300000000D00B0000BC070000235553008C1300001000000023475549440000009C1300002806000023426C6F620000000000000002000001571D02000900000000FA01330016000001000000350000000200000005000000050000000300000049000000050000000E00000004000000010000000300000000002B030100000000000600390260050600A602600506006D011D050F008005000006009501CF0306001C02CF030600FD01CF0306008D02CF0306005902CF0306007202CF030600AC01CF0306008101410506005F0141050600E001CF030600C701D6020600CB056A030A006D00E7050A00C004E7050A004506EC040A000F01EC040A000204E7050A00B203EC04060029046A030E00DD05D2050E001004D2050600ED006A0306007F036A0306000A00720606007504CF030E004101D20506005A032B00060054032B000E009E00D2050A002706EC040A00F5035B040A0063005B04060004006A030600D1006A0306000B036A030A00070535000A00B3045B040E00E103D2050E00A104D2050600CD021B06060013066A030E00B106D205060003006A0306007103720606007F0499030600DC046A0306001A016A0306009805CF030E004501D205000000001E00000000000100010001001000B1050000410001000100518027002B05518085002B055180E5002B05518067062B0551808F062B05502000000000960012032E050100D826000000009100880332050100B027000000009100AD003605010010280000000091001D043E050300A02800000000861817050600040000000100FD05020002004904000001008B04090017050100110017050600190017050A00290017051000310017051000390017051000410017051000490017051000510017051000590017051000610017051500690017051000710017051000790017051000110132066000110106016500A90017051000190194030600890017056A002101930471003101570106002901FF02750039017D0079008900CE047F00390197068700490108038D003901BD059200490139039A003901BD059F0049015500A5004901510106009900AE03A9004901DD008D004901C402AE008100FF0275003901BD05B30049010406B900B900C5007500A10078001000190151010600C10017050600C100A505BD0051016103C30061011500CB0061018F05D100C1004100D7003901BD05E000D1001705F600D10057060101D100F6000601D100C0030B01D900300514016901010018017101BB001D017901FF027500E1001705220181011F0328016901F0022F0189011F0135013901C4053B01810017014F0199015A005501E900A3065E01E900C4026601F10033047500F1008F006B01C90034018201A90142038801010117050600F9006E048D0101015F0693016101080398018100170506000E000400A7010E00080014020E000C005D020E00100090020E001400E9022E000B0044052E0013004D052E001B006C052E00230075052E002B0084052E00330084052E003B0084052E00430075052E004B008A052E00530084052E005B0084052E006300A2052E006B00CC052E007300D9051A00E70045017101048000000100000000000000000000000000150300000400000000000000000000009E014C00000000000400000000000000000000009E013500000000000400000000000000000000009E016A03000000000000000000546F55496E74333200484D4143534841323536006765745F55544638003C4D6F64756C653E005552490053797374656D2E494F0053797374656D2E446174610055706C6F616444617461006D73636F726C69620052656164004765744669656C64004462436F6D6D616E640053716C436F6D6D616E640053656E64005265706C616365004E616D657370616365006765745F537461747573436F64650048747470537461747573436F646500476574537461747573436F64650055726C456E636F6465006765745F4D6573736167650049446973706F7361626C65004765744E616D65004B65794E616D65004461746554696D6500546F556E6976657273616C54696D65006765745F506970650053716C506970650047657454797065006765745F496E76617269616E7443756C74757265006765745F526573706F6E73650048747470576562526573706F6E736500436C6F736500446973706F736500477569644174747269627574650044656275676761626C6541747472696275746500436F6D56697369626C6541747472696275746500417373656D626C795469746C6541747472696275746500417373656D626C7954726164656D61726B417474726962757465005461726765744672616D65776F726B41747472696275746500417373656D626C7946696C6556657273696F6E41747472696275746500417373656D626C79436F6E66696775726174696F6E41747472696275746500417373656D626C794465736372697074696F6E41747472696275746500436F6D70696C6174696F6E52656C61786174696F6E7341747472696275746500417373656D626C7950726F6475637441747472696275746500417373656D626C79436F7079726967687441747472696275746500417373656D626C79436F6D70616E794174747269627574650052756E74696D65436F6D7061746962696C6974794174747269627574650047657456616C756500456E636F64696E670053797374656D2E52756E74696D652E56657273696F6E696E6700546F426173653634537472696E6700546F537472696E6700476574537472696E670074726753656E6453424D736700436F6D70757465486173680053656E6453424D73672E646C6C00497344424E756C6C00476574526573706F6E736553747265616D004D656D6F727953747265616D007365745F4974656D0053797374656D0048617368416C676F726974686D0054696D655370616E00476574536173546F6B656E004F70656E0053797374656D2E476C6F62616C697A6174696F6E006765745F54726967676572416374696F6E006F705F5375627472616374696F6E0053797374656D2E5265666C656374696F6E00576562486561646572436F6C6C656374696F6E004462436F6E6E656374696F6E0053716C436F6E6E656374696F6E00576562457863657074696F6E004765744572726F7246726F6D457863657074696F6E006765745F5374617475734465736372697074696F6E007374617475734465736372697074696F6E0053797374656D2E446174612E436F6D6D6F6E00436F7079546F004669656C64496E666F0043756C74757265496E666F007765624578637000457865637574655363616C6172004874747052657175657374486561646572004462446174615265616465720053716C4461746152656164657200457865637574655265616465720049466F726D617450726F7669646572004D6963726F736F66742E53716C5365727665722E53657276657200436F6D6D616E644265686176696F72002E63746F720053797374656D2E446961676E6F7374696373006765745F546F74616C5365636F6E64730053797374656D2E52756E74696D652E496E7465726F7053657276696365730053797374656D2E52756E74696D652E436F6D70696C6572536572766963657300446562756767696E674D6F6465730047657442797465730042696E64696E67466C616773006765745F4865616465727300434C52547269676765727300436F6E63617400466F726D6174004F626A6563740053797374656D2E4E657400576562436C69656E740053797374656D2E446174612E53716C436C69656E7400636C69656E74006765745F4669656C64436F756E7400436F6E766572740053797374656D2E546578740053716C436F6E74657874006765745F54726967676572436F6E746578740053716C54726967676572436F6E74657874006765745F4E6F7700546F4172726179004163636F756E744B65790053797374656D2E53656375726974792E43727970746F67726170687900504B5175657279006F705F457175616C697479006F705F496E657175616C697479005765625574696C69747900000100133C006D006500730073006100670065003E00002F63006F006E007400650078007400200063006F006E006E0065006300740069006F006E003D00740072007500650000810F530045004C004500430054002000630061007300740028007200650073006F0075007200630065005F006100730073006F006300690061007400650064005F0065006E0074006900740079005F0069006400200061007300200069006E00740029002000460052004F004D0020007300790073002E0064006D005F007400720061006E005F006C006F0063006B007300200057004800450052004500200072006500710075006500730074005F00730065007300730069006F006E005F006900640020003D002000400040007300700069006400200061006E00640020007200650073006F0075007200630065005F00740079007000650020003D00200027004F0042004A004500430054002700018241730065006C0065006300740020006F0062006A006500630074005F006E0061006D0065002800690063002E006F0062006A006500630074005F006900640029002C00200063002E006E0061006D0065002000660072006F006D0020007300790073002E0069006E006400650078005F0063006F006C0075006D006E00730020006900630020006A006F0069006E0020007300790073002E0069006E00640065007800650073002000690020006F006E0020002800690063002E006F0062006A006500630074005F00690064003D0069002E006F0062006A006500630074005F0069006400200061006E0064002000690063002E0069006E006400650078005F00690064003D0069002E0069006E006400650078005F0069006400290020006A006F0069006E0020007300790073002E0063006F006C0075006D006E0073002000630020006F006E002000280063002E006F0062006A006500630074005F00690064003D00690063002E006F0062006A006500630074005F0069006400200061006E0064002000690063002E0063006F006C0075006D006E005F00690064003D0063002E0063006F006C0075006D006E005F00690064002900200077006800650072006500200069002E00690073005F007000720069006D006100720079005F006B00650079003D003100200061006E0064002000690063002E006F0062006A006500630074005F00690064003D00250020006F0072006400650072002000620079002000690063002E006B00650079005F006F007200640069006E0061006C0000032500000F3C007400610062006C0065003E0000113C002F007400610062006C0065003E0000093C0070006B003E00000B3C002F0070006B003E0000032C00002F3C0061006300740069006F006E003E0069006E0073006500720074003C002F0061006300740069006F006E003E00002D530045004C0045004300540020002A002000460052004F004D00200049004E00530045005200540045004400000B3C0072006F0077003E00001D3C0063006F006C0075006D006E0020006E0061006D0065003D002200000522003E0000133C002F0063006F006C0075006D006E003E00000D3C002F0072006F0077003E00002F3C0061006300740069006F006E003E007500700064006100740065003C002F0061006300740069006F006E003E00002F3C0061006300740069006F006E003E00640065006C006500740065003C002F0061006300740069006F006E003E00002B530045004C0045004300540020002A002000460052004F004D002000440045004C00450054004500440000153C002F006D006500730073006100670065003E00001745007800630065007000740069006F006E003A002000005B6100700070006C00690063006100740069006F006E002F00610074006F006D002B0078006D006C003B0074007900700065003D0065006E007400720079003B0063006800610072007300650074003D007500740066002D003800017F680074007400700073003A002F002F006D007600680073006500720076006900630065006200750073002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E00650074002F00740065007300740074006F007000690063002F006D006500730073006100670065007300000950004F005300540000053A00200000496D007600680073006500720076006900630065006200750073002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E006500740000030A0000595900480068004D0064004D0047003100330042002B007500720039006E0055004C0067006D0041004F006C004200380041005900460048006D003600500048002F0066003100350054004B0047004F005700770038003D0000675300680061007200650064004100630063006500730073005300690067006E00610074007500720065002000730072003D007B0030007D0026007300690067003D007B0031007D002600730065003D007B0032007D00260073006B006E003D007B0033007D00003352006F006F0074004D0061006E006100670065005300680061007200650064004100630063006500730073004B0065007900001B6D005F0057006500620052006500730070006F006E0073006500002320002800480074007400700053007400610074007500730043006F0064006500200000032900000000003DA6B642F08B50469346C0A22F37530700042001010803200001052001011111042001010E042001010245072E080E0E0E12451249124D1251125512451245124902020E02021159115912451249080E020212451249080E020212451249080E0202125D0E12611D050E08021265125D040000124D0400001251062002010E12550320001C0320000E0520020E0E0E07200112491180A1050002020E0E0420010E080700040E0E0E0E0E04200102080500020E0E0E0320000204200011590420011C080500010E1D0E032000080520001280A9072002011180AD0E0500001280B10520011D050E0820031D050E0E1D050600030E0E0E0E0E07081169116D090E12710E11690E0A2007010808080808080804000011690420001169080002116D116911690320000D040001090D0400010E0E052001011D050620011D051D050500010E1D050500001280C50900030E1280C90E1D1C090705127502127902080520001280CD08200212750E1180D107000202127512750420011C1C0520001180851007070E1279127D1280811D051180850E0520001280D5042000127D05200101127D0420001D050520010E1D0508B77A5C561934E0896C680074007400700073003A002F002F006D007600680073006500720076006900630065006200750073002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E00650074002F00740065007300740074006F00700069006300486D007600680073006500720076006900630065006200750073002E0073006500720076006900630065006200750073002E00770069006E0064006F00770073002E006E00650074003252006F006F0074004D0061006E006100670065005300680061007200650064004100630063006500730073004B0065007900585900480068004D0064004D0047003100330042002B007500720039006E0055004C0067006D0041004F006C004200380041005900460048006D003600500048002F0066003100350054004B0047004F005700770038003D008240730065006C0065006300740020006F0062006A006500630074005F006E0061006D0065002800690063002E006F0062006A006500630074005F006900640029002C00200063002E006E0061006D0065002000660072006F006D0020007300790073002E0069006E006400650078005F0063006F006C0075006D006E00730020006900630020006A006F0069006E0020007300790073002E0069006E00640065007800650073002000690020006F006E0020002800690063002E006F0062006A006500630074005F00690064003D0069002E006F0062006A006500630074005F0069006400200061006E0064002000690063002E0069006E006400650078005F00690064003D0069002E0069006E006400650078005F0069006400290020006A006F0069006E0020007300790073002E0063006F006C0075006D006E0073002000630020006F006E002000280063002E006F0062006A006500630074005F00690064003D00690063002E006F0062006A006500630074005F0069006400200061006E0064002000690063002E0063006F006C0075006D006E005F00690064003D0063002E0063006F006C0075006D006E005F00690064002900200077006800650072006500200069002E00690073005F007000720069006D006100720079005F006B00650079003D003100200061006E0064002000690063002E006F0062006A006500630074005F00690064003D00250020006F0072006400650072002000620079002000690063002E006B00650079005F006F007200640069006E0061006C0002060E030000010300000E070002081261100E0500010E12650801000800000000001E01000100540216577261704E6F6E457863657074696F6E5468726F7773010801000701000000000E01000953656E6453424D7367000005010000000017010012436F7079726967687420C2A920203230313900002901002432353663333934392D333037332D343065632D393738302D32623233316637333539306400000C010007312E302E302E3000004D01001C2E4E45544672616D65776F726B2C56657273696F6E3D76342E372E320100540E144672616D65776F726B446973706C61794E616D65142E4E4554204672616D65776F726B20342E372E320000000000C9FF39CD000000000200000059000000A8420000A824000000000000000000000000000010000000000000000000000000000000525344535AA95272F5E1C34796E0D21F0898C07A01000000433A5C55736572735C6D6976616E6875755C736F757263655C7265706F735C53656E6453424D73675C6F626A5C44656275675C53656E6453424D73672E706462002943000000000000000000004343000000200000000000000000000000000000000000000000000035430000000000000000000000005F436F72446C6C4D61696E006D73636F7265652E646C6C0000000000000000FF25002000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001001000000018000080000000000000000000000000000001000100000030000080000000000000000000000000000001000000000048000000586000001C03000000000000000000001C0334000000560053005F00560045005200530049004F004E005F0049004E0046004F0000000000BD04EFFE00000100000001000000000000000100000000003F000000000000000400000002000000000000000000000000000000440000000100560061007200460069006C00650049006E0066006F00000000002400040000005400720061006E0073006C006100740069006F006E00000000000000B0047C020000010053007400720069006E006700460069006C00650049006E0066006F0000005802000001003000300030003000300034006200300000001A000100010043006F006D006D0065006E007400730000000000000022000100010043006F006D00700061006E0079004E0061006D00650000000000000000003C000A000100460069006C0065004400650073006300720069007000740069006F006E0000000000530065006E006400530042004D00730067000000300008000100460069006C006500560065007200730069006F006E000000000031002E0030002E0030002E00300000003C000E00010049006E007400650072006E0061006C004E0061006D0065000000530065006E006400530042004D00730067002E0064006C006C0000004800120001004C006500670061006C0043006F007000790072006900670068007400000043006F0070007900720069006700680074002000A90020002000320030003100390000002A00010001004C006500670061006C00540072006100640065006D00610072006B007300000000000000000044000E0001004F0072006900670069006E0061006C00460069006C0065006E0061006D0065000000530065006E006400530042004D00730067002E0064006C006C00000034000A000100500072006F0064007500630074004E0061006D00650000000000530065006E006400530042004D00730067000000340008000100500072006F006400750063007400560065007200730069006F006E00000031002E0030002E0030002E003000000038000800010041007300730065006D0062006C0079002000560065007200730069006F006E00000031002E0030002E0030002E00300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000C000000583300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C005000000020200308205B106092A864886F70D010702A08205A23082059E020101310B300906052B0E03021A0500304C060A2B060104018237020104A03E303C3017060A2B06010401823702010F3009030100A004A20280003021300906052B0E03021A05000414E6B8B389033867DC2EF65C9B8D5060958FAC8618A082036E3082036A30820256A00302010202106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021D0500303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C5220436572743020170D3139303930343230333432385A180F32303939313233313034303030305A303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C52204365727430820122300D06092A864886F70D01010105000382010F003082010A0282010100BFA0F1A347A83B886B753FA158B65426B1DEECB2C46A9660135BDA45F56F8714800C515BE1609962B57A575E5A4339683CE1665C0E2E3812F6F6958EF96FE97893BD778D4230516005FE682CF5C263E6638A45B21F8F15CC07927B7937796E56591B1D706DF6726D84C646027C5FF28D2B567627A72E0DA6DDF41808D0DF9281E47E9C8AE007CF4DBAD4E349179A1C9FC3E9DD62EC9C448E9CFD3AA9E2DAE3DB9E86A028CFA1C24885C7DFA45FA9C8B35A98ED2EF31A3F5DDD30E03B6E64B1F135BAFA1FAB08199DD5DFAE0F894544100B91AECB117101DAA49E526A309B6915DD822C0285B24F3CFA2BF89088984E21B6674C2B1692B395985C0B51D9EF07D90203010001A370306E306C0603551D01046530638010F4A197D3F4E3ECF1D4E1E0417E935184A13D303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C52204365727482106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021D05000382010100853E32A6278392ECF28EABD5EB9F2297D3282949818DD9CF4E175AB32D9588B2B144A920D630788E10CBF66DF0A135E43FCD36892F1E779D6D9EEA3CDC417C480D9A95257313C79678235019A419DF1F61E085D5B23CADDEDA108B16DF4C6C31658D56816A85424D90F6F715C271C9A6A642CE987841B31F41CFB2522CAC23C3D69DC6B9D8F5ED237E756425BBE288ADF80F1BE6971A7A0CA3BE442461B17DA9DF975798B1642F1686DD962DDAF341C76697A98E403F812311AA0B146580E458C9301E7BE02E2D33511F2461591A6FD163F8E78AD80E79B58B9D5F7CBBE386DE0F7E610A305777FB35BD1B6C4F55CCD11A5E9F04C5558DA24A62BEDBE98A7EE3318201CA308201C6020101304F303B310B300906035504061302555331163014060355040A130D6D6963726F736F66742E636F6D311430120603550403130B53514C434C52204365727402106DFC260EB312E79845D7F0B3CC0E5088300906052B0E03021A0500A0523010060A2B06010401823702010C31023000301906092A864886F70D010903310C060A2B060104018237020104302306092A864886F70D010904311604143C43416D492468ADBD3875E7C021D8AC4AD3C867300D06092A864886F70D01010105000482010009DD9FAE160ECC1FBF41B8DC075E32D501C51B06CB22DDBCDE90CC32FA07FE48578B3EA5FF49D1445E94A0AAC0B60C60E8A29054CEECE28ADC869E2E7CF4BD28DE62020DB26699A9495EB44017323183319A822BDE5224E3DE89A4F2A008903BD6EF489E5644241574382F44C1DA896F414CFC7F829DD4C78D3871D378966014C547E09AE29E86D525A9C5E48F79B101201808CAB89AE22A0D97F1E8EFE45E860A72D8E6F34583EBF3CB82F1ED8531A8117C287DBF579B83BF13472C2BA816C8CAD961FEBA7A097D27550E479B663726217A577D0A7E3D61DDAEBFA38191A5E1F7B6CF132DB51FEF5EC94EB80B2A1E1D510702A17946ECD32BDCC6A5FE1B83C3000000
+WITH PERMISSION_SET = UNSAFE
+GO
+CREATE TRIGGER testclr
+ON dbo.foo
+FOR INSERT, UPDATE, DELETE
+AS
+EXTERNAL NAME SendSBMsg.CLRTriggers.trgSendSBMsg;
+GO
+exec sp_configure 'clr enabled',1
+reconfigure with override
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/Properties/AssemblyInfo.cs b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..abf5740
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SendSBMsg")]
+[assembly: AssemblyDescription("POC of CLR Trigger to send a message to Azure Service Bus")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("SendSBMsg")]
+[assembly: AssemblyCopyright("Copyright © 2019 Microsoft Corporation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("256c3949-3073-40ec-9780-2b231f73590d")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/SendSBMsg.csproj b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/SendSBMsg.csproj
new file mode 100644
index 0000000..b24d38a
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/SendSBMsg.csproj
@@ -0,0 +1,54 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {256C3949-3073-40EC-9780-2B231F73590D}
+ Library
+ Properties
+ SendSBMsg
+ SendSBMsg
+ v4.7.2
+ 512
+ true
+
+
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\signtool.exe" sign /v /p MySecurePW$ /f "C:\Users\mivanhuu\source\repos\DMJGitSourceControl\Private\IP and Scripts\Tools\SQLServiceBusPOC\SendSBMsg\SQLCLR-Cert.pfx" "$(TargetPath)"
+
+
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/SendSBMsg.sln b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/SendSBMsg.sln
new file mode 100644
index 0000000..edbb27e
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/SendSBMsg.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29215.179
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendSBMsg", "SendSBMsg.csproj", "{256C3949-3073-40EC-9780-2B231F73590D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {256C3949-3073-40EC-9780-2B231F73590D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {256C3949-3073-40EC-9780-2B231F73590D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {256C3949-3073-40EC-9780-2B231F73590D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {256C3949-3073-40EC-9780-2B231F73590D}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {8252FC0D-8CDD-42BE-A614-55AA5FD387E9}
+ EndGlobalSection
+EndGlobal
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/Sql Ins-Upd-Del.sql b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/Sql Ins-Upd-Del.sql
new file mode 100644
index 0000000..5d53f4c
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/Sql Ins-Upd-Del.sql
@@ -0,0 +1,11 @@
+INSERT INTO [dbo].[foo] ([a],[bar],[bigstuff],[modified])
+VALUES (5, 42, 'TESTING TESTING 123', getdate())
+GO
+update [test].[dbo].[foo]
+set bigstuff='TESTING-Interation-39- CLR Trigger'
+where a in (2,3)
+go
+/*
+delete from foo where a=5
+*/
+go
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/UseAssembly.sql b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/UseAssembly.sql
new file mode 100644
index 0000000..386c8aa
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/UseAssembly.sql
@@ -0,0 +1,30 @@
+use WideWorldImporters
+go
+DROP TRIGGER sales.testclr_SO
+GO
+DROP TRIGGER sales.testclr_SOL
+GO
+DROP TRIGGER sales.testclr_SI
+GO
+DROP ASSEMBLY SendSBMsg;
+GO
+CREATE ASSEMBLY SendSBMsg FROM 'C:\Users\mivanhuu\source\repos\DMJGitSourceControl\Private\IP and Scripts\Tools\SQLServiceBusPOC\SendSBMsg\bin\Debug\SendSBMsg.dll' WITH PERMISSION_SET = UNSAFE;
+go
+CREATE TRIGGER testclr_SO
+ON Sales.Orders
+FOR INSERT, UPDATE, DELETE
+AS
+EXTERNAL NAME SendSBMsg.CLRTriggers.trgSendSBMsg;
+go
+CREATE TRIGGER testclr_SOL
+ON Sales.OrderLines
+FOR INSERT, UPDATE, DELETE
+AS
+EXTERNAL NAME SendSBMsg.CLRTriggers.trgSendSBMsg;
+go
+CREATE TRIGGER testclr_SI
+ON Sales.Invoices
+FOR INSERT, UPDATE, DELETE
+AS
+EXTERNAL NAME SendSBMsg.CLRTriggers.trgSendSBMsg;
+go
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/app.config b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/app.config
new file mode 100644
index 0000000..37f40a2
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsg/app.config
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/App.config b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/ConfigServiceBroker.sql b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/ConfigServiceBroker.sql
new file mode 100644
index 0000000..e67e273
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/ConfigServiceBroker.sql
@@ -0,0 +1,272 @@
+-- This code was borrowed from https://sqlperformance.com/2014/03/sql-performance/configuring-service-broker
+
+-- Create the message types
+CREATE MESSAGE TYPE [AsyncRequest] VALIDATION = WELL_FORMED_XML;
+CREATE MESSAGE TYPE [AsyncResult] VALIDATION = WELL_FORMED_XML;
+GO
+-- Create the contract
+CREATE CONTRACT [AsyncContract]
+(
+ [AsyncRequest] SENT BY INITIATOR,
+ [AsyncResult] SENT BY TARGET
+);
+GO
+-- Create the processing queue and service - specify the contract to allow sending to the service
+CREATE QUEUE ProcessingQueue;
+CREATE SERVICE [ProcessingService] ON QUEUE ProcessingQueue ([AsyncContract]);
+GO
+-- Create the request queue and service
+CREATE QUEUE RequestQueue;
+CREATE SERVICE [RequestService] ON QUEUE RequestQueue;
+GO
+-- Create the wrapper procedure for sending messages
+CREATE PROCEDURE dbo.SendBrokerMessage
+ @FromService SYSNAME,
+ @ToService SYSNAME,
+ @Contract SYSNAME,
+ @MessageType SYSNAME,
+ @MessageBody XML
+AS
+BEGIN
+ SET NOCOUNT ON;
+
+ DECLARE @conversation_handle UNIQUEIDENTIFIER;
+
+ BEGIN TRANSACTION;
+
+ BEGIN DIALOG CONVERSATION @conversation_handle
+ FROM SERVICE @FromService
+ TO SERVICE @ToService
+ ON CONTRACT @Contract
+ WITH ENCRYPTION = OFF;
+
+ SEND ON CONVERSATION @conversation_handle
+ MESSAGE TYPE @MessageType(@MessageBody);
+
+ COMMIT TRANSACTION;
+END
+GO
+/*
+-- Send a request
+EXECUTE dbo.SendBrokerMessage
+ @FromService = N'RequestService',
+ @ToService = N'ProcessingService',
+ @Contract = N'AsyncContract',
+ @MessageType = N'AsyncRequest',
+ @MessageBody = N'12345';
+
+-- Check for message on processing queue
+SELECT CAST(message_body AS XML) FROM ProcessingQueue;
+GO
+*/
+
+-- Create processing procedure for processing queue
+CREATE PROCEDURE dbo.ProcessingQueueActivation
+AS
+BEGIN
+ SET NOCOUNT ON;
+
+ DECLARE @conversation_handle UNIQUEIDENTIFIER;
+ DECLARE @message_body XML;
+ DECLARE @message_type_name sysname;
+
+ WHILE (1=1)
+ BEGIN
+ BEGIN TRANSACTION;
+
+ WAITFOR
+ (
+ RECEIVE TOP (1)
+ @conversation_handle = conversation_handle,
+ @message_body = CAST(message_body AS XML),
+ @message_type_name = message_type_name
+ FROM ProcessingQueue
+ ), TIMEOUT 5000;
+
+ IF (@@ROWCOUNT = 0)
+ BEGIN
+ ROLLBACK TRANSACTION;
+ BREAK;
+ END
+
+ IF @message_type_name = N'AsyncRequest'
+ BEGIN
+ -- Handle complex long processing here
+ declare @resp nvarchar(max)
+ SELECT @resp = dbo.SendSBMsg(cast(@message_body as nvarchar(max)))
+
+ -- Build reply message and send back
+ DECLARE @reply_message_body XML = N'' + @resp + '';
+
+ SEND ON CONVERSATION @conversation_handle
+ MESSAGE TYPE [AsyncResult] (@reply_message_body);
+ END
+
+ -- If end dialog message, end the dialog
+ ELSE IF @message_type_name = N'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
+ BEGIN
+ END CONVERSATION @conversation_handle;
+ END
+
+ -- If error message, log and end conversation
+ ELSE IF @message_type_name = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'
+ BEGIN
+ -- Log the error code and perform any required handling here
+ -- End the conversation for the error
+ END CONVERSATION @conversation_handle;
+ END
+
+ COMMIT TRANSACTION;
+ END
+END
+GO
+-- Create procedure for processing replies to the request queue
+CREATE PROCEDURE dbo.RequestQueueActivation
+AS
+BEGIN
+ SET NOCOUNT ON;
+
+ DECLARE @conversation_handle UNIQUEIDENTIFIER;
+ DECLARE @message_body XML;
+ DECLARE @message_type_name sysname;
+
+ WHILE (1=1)
+ BEGIN
+ BEGIN TRANSACTION;
+
+ WAITFOR
+ (
+ RECEIVE TOP (1)
+ @conversation_handle = conversation_handle,
+ @message_body = CAST(message_body AS XML),
+ @message_type_name = message_type_name
+ FROM RequestQueue
+ ), TIMEOUT 5000;
+
+ IF (@@ROWCOUNT = 0)
+ BEGIN
+ ROLLBACK TRANSACTION;
+ BREAK;
+ END
+
+ IF @message_type_name = N'AsyncResult'
+ BEGIN
+ SELECT @message_body;
+
+ -- Since this is all the work being done, end the conversation to send the EndDialog message
+ END CONVERSATION @conversation_handle;
+ END
+
+ -- If end dialog message, end the dialog
+ ELSE IF @message_type_name = N'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
+ BEGIN
+ END CONVERSATION @conversation_handle;
+ END
+
+ -- If error message, log and end conversation
+ ELSE IF @message_type_name = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'
+ BEGIN
+ END CONVERSATION @conversation_handle;
+ END
+
+ COMMIT TRANSACTION;
+ END
+END
+GO
+
+/*
+-- Process the message from the processing queue
+EXECUTE dbo.ProcessingQueueActivation;
+GO
+
+-- Check for reply message on request queue
+SELECT CAST(message_body AS XML) FROM RequestQueue;
+GO
+
+-- Process the message from the request queue
+EXECUTE dbo.RequestQueueActivation;
+GO
+*/
+
+-- Alter the processing queue to specify internal activation
+ALTER QUEUE ProcessingQueue
+ WITH ACTIVATION
+ (
+ STATUS = ON,
+ PROCEDURE_NAME = dbo.ProcessingQueueActivation,
+ MAX_QUEUE_READERS = 10,
+ EXECUTE AS SELF
+ );
+GO
+-- Alter the request queue to specify internal activation
+ALTER QUEUE RequestQueue
+ WITH ACTIVATION
+ (
+ STATUS = ON,
+ PROCEDURE_NAME = dbo.RequestQueueActivation,
+ MAX_QUEUE_READERS = 10,
+ EXECUTE AS SELF
+ );
+GO
+
+ /*
+-- Test automated activation
+-- Send a request
+
+EXECUTE dbo.SendBrokerMessage
+ @FromService = N'RequestService',
+ @ToService = N'ProcessingService',
+ @Contract = N'AsyncContract',
+ @MessageType = N'AsyncRequest',
+ @MessageBody = N'
+
+a
+update
+
+
+2
+2
+
+
+2
+2
+
+
+TEST4242
+TEST42
+
+
+2019-06-20 4:05:45 PM
+2019-06-20 4:05:45 PM
+
+
+
+
+3
+3
+
+
+3
+3
+
+
+TEST4242
+TEST42
+
+
+2019-06-20 4:05:45 PM
+2019-06-20 4:05:45 PM
+
+
+';
+
+-- Check for message on processing queue
+-- nothing is there because it was automatically processed
+SELECT CAST(message_body AS XML) FROM ProcessingQueue;
+GO
+
+-- Check for reply message on request queue
+-- nothing is there because it was automatically processed
+SELECT CAST(message_body AS XML) FROM RequestQueue;
+GO
+*/
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/Properties/AssemblyInfo.cs b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..94260fd
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SendSBMsgUDF")]
+[assembly: AssemblyDescription("POC of CLR UDF to send a message to Azure Service Bus")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SendSBMsgUDF")]
+[assembly: AssemblyCopyright("Copyright © 2019 Microsoft Corporation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("18fe384d-0eee-438d-a34c-796af81c5939")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/SendSBMsgUDF.cs b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/SendSBMsgUDF.cs
new file mode 100644
index 0000000..8a35b98
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/SendSBMsgUDF.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Data;
+using Microsoft.SqlServer.Server;
+using System.Data.SqlTypes;
+using System.Data.SqlClient;
+using System.Text;
+using System.IO;
+using System.Net;
+using System.Security.Cryptography;
+using System.Globalization;
+using System.Reflection;
+using System.Threading;
+
+/*
+Title: SendSBMsgUDF
+Author: Mitch van Huuksloot,
+ Data Migration Jumpstart Team
+
+The Sample Code below was developed by Microsoft Corporation technical architects. Because Microsoft must respond to changing market conditions, this document should not be interpreted as an invitation to contract or a commitment on the part of Microsoft.
+Microsoft has provided high level guidance in this artifact with the understanding that the reader would undertake detailed design and comprehensive reviews of the overall solution before the solution would be implemented/delivered.
+Microsoft is not responsible for the final implementation undertaken.
+MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED WITH RESPECT TO THE INFORMATION CONTAINED HEREIN.
+*/
+
+
+public class CLRUDF
+{
+ private const string URI = "https://mvhsbpoc.servicebus.windows.net/tablechange";
+ private const string Namespace = "mvhsbpoc.servicebus.windows.net";
+ private const string KeyName = "RootManageSharedAccessKey";
+ private const string AccountKey = "pjUlu7o4ktS/LJNCzJ9azJTk7n9PV+BEJE4mxS0zX0q=";
+
+ [SqlFunction(Name = "SendSBMsgUDF", DataAccess = DataAccessKind.None, IsDeterministic = false)]
+ public static SqlString SendSBMsgUDF(SqlString msgbody)
+ {
+ DateTime start = DateTime.Now;
+
+ //send message to Service Bus
+ try
+ {
+ string sasToken = GetSasToken();
+ WebClient webClient = new WebClient();
+ webClient.Headers[HttpRequestHeader.Authorization] = sasToken;
+ webClient.Headers[HttpRequestHeader.ContentType] = "application/atom+xml;type=entry;charset=utf-8";
+ var body = Encoding.UTF8.GetBytes(msgbody.ToString());
+ webClient.UploadData(URI + "/messages", "POST", body);
+ string httpmsg;
+ int status = GetStatusCode(webClient, out httpmsg);
+ if (status < 300) return "Elapsed time: " + DateTime.Now.Subtract(start).TotalMilliseconds.ToString();
+ else return status.ToString() + ": " + httpmsg;
+ }
+ catch (WebException ex)
+ {
+ return GetErrorFromException(ex);
+ }
+ catch (Exception ex)
+ {
+ return ex.Message;
+ }
+ }
+
+ private static string GetSasToken()
+ {
+ // Set token lifetime to 20 minutes.
+ DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
+ TimeSpan diff = DateTime.Now.ToUniversalTime() - origin;
+ uint tokenExpirationTime = Convert.ToUInt32(diff.TotalSeconds) + (20 * 60);
+ string stringToSign = WebUtility.UrlEncode(Namespace) + "\n" + tokenExpirationTime.ToString();
+ var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(AccountKey));
+ var signature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(stringToSign)));
+ return string.Format(CultureInfo.InvariantCulture, "SharedAccessSignature sr={0}&sig={1}&se={2}&skn={3}", WebUtility.UrlEncode(Namespace), WebUtility.UrlEncode(signature), tokenExpirationTime, KeyName);
+ }
+
+ private static int GetStatusCode(WebClient client, out string statusDescription)
+ {
+ FieldInfo responseField = client.GetType().GetField("m_WebResponse", BindingFlags.Instance | BindingFlags.NonPublic);
+ if (responseField != null)
+ {
+ HttpWebResponse response = responseField.GetValue(client) as HttpWebResponse;
+ if (response != null)
+ {
+ statusDescription = response.StatusDescription;
+ return (int)response.StatusCode;
+ }
+ }
+ statusDescription = null;
+ return 0;
+ }
+
+ private static string GetErrorFromException(WebException webExcp)
+ {
+ var exceptionMessage = webExcp.Message;
+
+ try
+ {
+ var httpResponse = (HttpWebResponse)webExcp.Response;
+ var stream = httpResponse.GetResponseStream();
+ var memoryStream = new MemoryStream();
+
+ stream.CopyTo(memoryStream);
+
+ var receivedBytes = memoryStream.ToArray();
+ exceptionMessage = Encoding.UTF8.GetString(receivedBytes)
+ + " (HttpStatusCode "
+ + httpResponse.StatusCode.ToString()
+ + ")";
+ }
+ catch (Exception ex)
+ {
+ exceptionMessage = ex.Message;
+ }
+
+ return exceptionMessage;
+ }
+
+}
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/SendSBMsgUDF.csproj b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/SendSBMsgUDF.csproj
new file mode 100644
index 0000000..033f347
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/SendSBMsgUDF.csproj
@@ -0,0 +1,59 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {18FE384D-0EEE-438D-A34C-796AF81C5939}
+ Library
+ SendSBMsgUDF
+ SendSBMsgUDF
+ v4.7.2
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\signtool.exe" sign /v /p MySecurePW$ /f "C:\Users\mivanhuu\source\repos\DMJGitSourceControl\Private\IP and Scripts\Tools\SQLServiceBusPOC\SendSBMsg\SQLCLR-Cert.pfx" "$(TargetPath)"
+
+
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/SendSBMsgUDF.sln b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/SendSBMsgUDF.sln
new file mode 100644
index 0000000..dd1fc1a
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/SendSBMsgUDF.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29230.47
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendSBMsgUDF", "SendSBMsgUDF.csproj", "{18FE384D-0EEE-438D-A34C-796AF81C5939}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {18FE384D-0EEE-438D-A34C-796AF81C5939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {18FE384D-0EEE-438D-A34C-796AF81C5939}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {18FE384D-0EEE-438D-A34C-796AF81C5939}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {18FE384D-0EEE-438D-A34C-796AF81C5939}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {9F27F4FC-D466-471E-B058-7729F4B0CB15}
+ EndGlobalSection
+EndGlobal
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/UseAssembly.sql b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/UseAssembly.sql
new file mode 100644
index 0000000..782779a
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/SendSBMsgUDF/UseAssembly.sql
@@ -0,0 +1,156 @@
+DROP TRIGGER testclr -- drop CLR trigger in case it is active
+GO
+
+-- Register CLR Assembly and associated function
+DROP FUNCTION SendSBMsg
+go
+DROP ASSEMBLY SendSBMsgUDF;
+GO
+CREATE ASSEMBLY SendSBMsgUDF FROM 'C:\Users\mivanhuu\source\repos\DMJGitSourceControl\Private\IP and Scripts\Tools\SQLServiceBusPOC\SendSBMsgUDF\bin\Debug\SendSBMsgUDF.dll' WITH PERMISSION_SET = UNSAFE;
+go
+CREATE FUNCTION SendSBMsg(@msgbody nvarchar(max))
+RETURNS nvarchar(max)
+AS
+EXTERNAL NAME SendSBMsgUDF.CLRUDF.SendSBMsgUDF;
+go
+
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- DIRECT SEND TO SERVICE BUS TRIGGER
+drop trigger trgsenddirect_SO
+go
+create trigger trgsenddirect_SO on Sales.Orders
+for insert, update, delete
+as
+declare @inserted int
+select @inserted=count(*) from inserted
+declare @msgbody nvarchar(max)
+if (@inserted > 0)
+ begin
+ set @msgbody = (select * from inserted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'insert' + @msgbody + ''
+ end
+else
+ begin
+ set @msgbody = (select * from deleted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'delete' + @msgbody + ''
+ end
+select dbo.SendSBMsg(@msgbody)
+go
+drop trigger trgsenddirect_SOL
+go
+create trigger trgsenddirect_SOL on Sales.OrderLines
+for insert, update, delete
+as
+declare @inserted int
+select @inserted=count(*) from inserted
+declare @msgbody nvarchar(max)
+if (@inserted > 0)
+ begin
+ set @msgbody = (select * from inserted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'insert' + @msgbody + ''
+ end
+else
+ begin
+ set @msgbody = (select * from deleted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'delete' + @msgbody + ''
+ end
+select dbo.SendSBMsg(@msgbody)
+go
+drop trigger trgsenddirect_SI
+go
+create trigger trgsenddirect_SI on Sales.Invoices
+for insert, update, delete
+as
+declare @inserted int
+select @inserted=count(*) from inserted
+declare @msgbody nvarchar(max)
+if (@inserted > 0)
+ begin
+ set @msgbody = (select * from inserted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'insert' + @msgbody + ''
+ end
+else
+ begin
+ set @msgbody = (select * from deleted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'delete' + @msgbody + ''
+ end
+select dbo.SendSBMsg(@msgbody)
+go
+
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+-- SEND TO SERVICE BUS VIA SERVICE BROKER TRIGGER (Service Broker queue and contracts need to be set up)
+drop trigger trgSBtest_SO
+go
+create trigger trgSBtest_SO on Sales.Orders
+for insert, update, delete
+as
+declare @inserted int
+select @inserted=count(*) from inserted
+declare @msgbody nvarchar(max)
+if (@inserted > 0)
+ begin
+ set @msgbody = (select * from inserted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'insert' + @msgbody + ''
+ end
+else
+ begin
+ set @msgbody = (select * from deleted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'delete' + @msgbody + ''
+ end
+EXECUTE dbo.SendBrokerMessage
+ @FromService = N'RequestService',
+ @ToService = N'ProcessingService',
+ @Contract = N'AsyncContract',
+ @MessageType = N'AsyncRequest',
+ @MessageBody = @msgbody
+go
+drop trigger trgSBtest_SOL
+go
+create trigger trgSBtest_SOL on Sales.OrderLines
+for insert, update, delete
+as
+declare @inserted int
+select @inserted=count(*) from inserted
+declare @msgbody nvarchar(max)
+if (@inserted > 0)
+ begin
+ set @msgbody = (select * from inserted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'insert' + @msgbody + ''
+ end
+else
+ begin
+ set @msgbody = (select * from deleted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'delete' + @msgbody + ''
+ end
+EXECUTE dbo.SendBrokerMessage
+ @FromService = N'RequestService',
+ @ToService = N'ProcessingService',
+ @Contract = N'AsyncContract',
+ @MessageType = N'AsyncRequest',
+ @MessageBody = @msgbody
+go
+drop trigger trgSBtest_SI
+go
+create trigger trgSBtest_SI on Sales.Invoices
+for insert, update, delete
+as
+declare @inserted int
+select @inserted=count(*) from inserted
+declare @msgbody nvarchar(max)
+if (@inserted > 0)
+ begin
+ set @msgbody = (select * from inserted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'insert' + @msgbody + ''
+ end
+else
+ begin
+ set @msgbody = (select * from deleted for xml path)
+ select @msgbody = '' + REPLACE(@@SERVERNAME, '\', '%5C') + 'delete' + @msgbody + ''
+ end
+EXECUTE dbo.SendBrokerMessage
+ @FromService = N'RequestService',
+ @ToService = N'ProcessingService',
+ @Contract = N'AsyncContract',
+ @MessageType = N'AsyncRequest',
+ @MessageBody = @msgbody
+go
\ No newline at end of file
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/Update Test.sql b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/Update Test.sql
new file mode 100644
index 0000000..c6b4494
--- /dev/null
+++ b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/Update Test.sql
@@ -0,0 +1 @@
+update [WideWorldImporters].[Sales].[Orders] set comments='Test firing of CLR trigger on 5 row update', PerfTest=SYSDATETIME() where OrderID between 1 and 5;
diff --git a/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/Using Azure Service Bus to Provide Messaging Between Azure SQL MI Instances.docx b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/Using Azure Service Bus to Provide Messaging Between Azure SQL MI Instances.docx
new file mode 100644
index 0000000..3b359c2
Binary files /dev/null and b/IP and Scripts/SQLServiceBusPOC/SQLServiceBusPOC/Using Azure Service Bus to Provide Messaging Between Azure SQL MI Instances.docx differ