Install .NET Core SDK on elementary OS

At this writing, I’m running elementary OS 0.4.1 Loki, which is based on Ubuntu 16.04.2 LTS. (It is important to know the Ubuntu version, since the .NET Core SDK distribution has different source list for different Linux distros and versions.)

.NET Core SDK version: v2.1.301

  1. Go to the All .NET Download site of Microsoft at https://www.microsoft.com/net/download/all.
  2. Click the link to the SDK version you want. For example, 2.1 SDK (v2.1.301) downloads.
  3. Choose the link of the Linux distro and version you are using. For example, since I’m running elementary OS, I click on the Ubuntu 14.04 Instructions link.
  4. Follow the instruction on the page to register Microsoft key and repository, and to follow steps to install .NET SDK.

    In my case, since my connection to the internet is behind a proxy server, I first make sure that wget is using proxy (see this post about [wget proxy setting]).

    Register Microsoft key and package source

    I type in the following wget command to get the .deb package from Microsoft.

    ~$ wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
    --2018-06-27 11:03:08--  https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
    Connecting to 10.0.2.2:3128... connected.
    Proxy request sent, awaiting response... 200 OK
    Length: 2452 (2.4K) [application/octet-stream]
    Saving to: ‘packages-microsoft-prod.deb’
    
    packages-microsoft-prod.deb                                 100%[==========================================================================================================================================>]   2.39K  --.-KB/s    in 0s      
    
    2018-06-27 11:03:09 (469 MB/s) - ‘packages-microsoft-prod.deb’ saved [2452/2452]
    

    I then install the downloaded package

    ~$ sudo dpkg -i packages-microsoft-prod.deb
    Selecting previously unselected package packages-microsoft-prod.
    (Reading database ... 173634 files and directories currently installed.)
    Preparing to unpack packages-microsoft-prod.deb ...
    Unpacking packages-microsoft-prod (1.0-3) ...
    Setting up packages-microsoft-prod (1.0-3) ...
    

    Which does three things: 1) adds the Microsoft packages information to the source list; 2) adds the Microsoft key to the trusted list; and 3) sets root as the owner of the two added files. See directory listing below:

    ~$ ls -l /etc/apt/sources.list.d/
    total 16
    -rw-r--r-- 1 root root  56 Feb 14 10:56 appcenter.list
    -rw-r--r-- 1 root root 144 Feb 14 10:56 elementary.list
    -rw-r--r-- 1 root root  78 Nov 27  2017 microsoft-prod.list
    -rw-r--r-- 1 root root 152 Feb 14 10:56 patches.list
    ~$ ls -l /etc/apt/trusted.gpg.d
    total 4
    -rw-r--r-- 1 root root 641 Jan 23  2017 microsoft-prod.gpg
    

    Install .NET Core SDK

    Make sure that https download transport for APT is installed and up to date.

    ~$ sudo apt-get install apt-transport-https

    downloads the package lists from the repositories and updates them to get information on the newest versions of packages and their dependencies.

    ~$ sudo apt-get update

    Install .NET SDK Core 2.1

    ~$ sudo apt-get -y install dotnet-sdk-2.1

    At the end of the installation, you will see the following information…

    This software may collect information about you and your use of the software, and send that to Microsoft.
    Please visit http://aka.ms/dotnet-cli-eula for more information.
    Welcome to .NET Core!
    ---------------------
    Learn more about .NET Core: https://aka.ms/dotnet-docs
    Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
    
    Telemetry
    ---------
    The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
    
    Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
    
    Configuring...
    --------------
    A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
    

    Verify that .NET Core 2.1 is installed

    ~$ dotnet --version
    2.1.301
    

Replace all empty character-fields in an MSSQL table with NULL

One good way is to build a dynamic SQL statement, and then run it with sp_executesql. The syntax of the sp_executesql statement is as follow: (See detail documentation of the statement on Microsoft Developer Network site)

sp_executesql [@stmt=] statement
[
  {, [@params=] N'@parameter_name data_type [OUT|OUTPUT][,...n]'} 
     {, [@param1=]'value1'[,...n]}
]
  1. Declare a unicode variable for the dynamic SQL statement:

    DECLARE @sSQL nvarchar(max) = ''
  2. Build your dynamic SQL statment.

    1. For example, if you wish to replace all empty character fields in table [myBlog] then the statement would be:

      SELECT
      @sSQL = @sSQL + 'UPDATE [' + TABLE_NAME + '] SET [' +
          COLUMN_NAME + '] = NULL WHERE ([' + COLUMN_NAME +
          '] = '''')' + CHAR(13)
      FROM INFORMATION_SCHEMA.COLUMNS
      WHERE (TABLE_NAME='myBlog') AND (DATA_TYPE LIKE '%char%')
      
    2. Or, if you wish to replace all of them in all the tables of the current database:

      SELECT
      @sSQL = @sSQL + 'UPDATE [' + TABLE_NAME + '] SET [' +
          COLUMN_NAME + '] = NULL WHERE ([' + COLUMN_NAME +
          '] = '''')' + CHAR(13)
      FROM INFORMATION_SCHEMA.COLUMNS
      WHERE (DATA_TYPE LIKE '%char%')
      
  3. Execute the dynamic SQL statement.

    EXEC sp_executesql @sSQL
    

SQL Server Logs

Reading the SQL Server error logs.

sp_readerrorlog

sp_readerrorlog is a stored procedure in the master database. It checks that the user is part of the securityadmin, then calls xp_readerrorlog. Header of the log gives server information and location of the log files.

Parameters
Order Type Description
1 int number of the log file. default is 0 for current file
2 int LogType, default 1. 1 = SQLServer logs, 2 = SQLAgent logs, 3 = full text logs
3 varchar(255) default NULL — search string for the log entry
4 varchar(255) default NULL — search string for the log entry
5 datetime from date-time
6 datetime to date-time
7 varchar Order, default to “ASC”. “ASC” or “DESC

Start a new error log

sp_cycle_errorlog

By default the number of logs is 7.