Posts

Showing posts from 2016

C# SELF DESTRUCT CONSOLE APP

Just call this method at the very end of your C# application to delete application’s executable file. /// <summary> /// This method deletes the exe that calls it. /// /// This method must be called right at the end of the application. /// </summary> private static void SelfDestroy() {      var startInfo = new ProcessStartInfo();      startInfo.FileName = "cmd.exe" ;      startInfo.RedirectStandardInput = true ;      startInfo.UseShellExecute = false ;        var process = new Process();      process.StartInfo = startInfo;      process.Start();        // The delay is just making sure the exe to delete is done      // running.      var delayPings = 2;      var exeName = AppDomain.CurrentDomain.Friend...

Get the Differences between two Databases (Preferably Similar)

Run the following sql query for each database. SELECT   ST.NAME   'TABLE'             , SC.NAME   'COLUMN'            , T.NAME   'COLUMN TYPE'             ,SC.MAX_LENGTH 'LENGTH', SC.is_nullable ,object_definition(SC.default_ object_id) AS defaultVal               FROM SYS.TABLES ST INNER JOIN SYS.COLUMNS SC ON ST.OBJECT_ID = SC.OBJECT_ID INNER JOIN SYS.TYPES T ON SC.SYSTEM_TYPE_ID = T.SYSTEM_TYPE_ID             AND SC.SYSTEM_TYPE_ID = T.USER_TYPE_ID LEFT JOIN SYS.EXTENDED_PROPERTIES EX ON EX.MINOR_ID = SC.COLUMN_ID             AND EX.MAJOR_ID = ST.OBJECT_ID  order by   ST.NAME , SC.NAME Save the outputs as  .CSV files. Build an EXE file for the following code. Put the two CSV files and the exe file in a folder Run ...