Converting Large Integers Stored as Floats to NVarChars in SQL (without Scientific Notation)

Converting SQL data types can be a bit finicky, and, at least for this guy, converting a stored, large integer value to a string is not intuitive at all.

I mostly run into this when I import values from some data source like an Excel sheet that stores values like tracking numbers as a float. From there, I usually write a cursor to update tables in my system with these values, and when those tables use a column type of varchar or nvarchar, you have to convert from float type to varchar

One would think that using CAST(varchar(50), TrackingNumber) would do the trick, but when this cast is made, the value is stored in scientific notation.

The real trick is to first convert the int value to a bigint and THEN convert it to a varchar, as shown below:

CONVERT(varchar(50), CONVERT(bigint, TrackingNumber))

Preloading Websites on IIS 7.5

Earlier this year, I built a .Net Core Web Application and deployed it on IIS 7.5. I noticed right away that it was extremely slow on initial load. This was confusing because I tested deployment to Azure and the performance was great. I struggled to figure out why it loaded so slowly but all of my .Net Framework sites ran quickly.

I struggled to find an answer for a long time, but while reading through documentation while setting up another application I came across this bit of information:

http://cdn.rssbus.com/help/ARC/mft/pg_serveriis7dot5.htm

Preloading Applications

You can make use of the preloading feature to have applications running before users connect. In your ApplicationHost.config, add the preloadEnabled attribute to the <application> element associated with the application. The application node is a child element of the sites node:

<sites>
<site name="Default Web Site" id="1">
  <application path="/rssbus" applicationPool="DefaultAppPool"  preloadEnabled="true">
  
  ...

When PreloadEnabled is set to true, IIS will simulate a user request to the default page of the website or virtual directory so that the application initializes.

While it technically is a bit of a workaround since it doesn’t solve the root problem I experience with preloading, it has kept my application loading quickly since I enabled it.

Enabling TLS 1.2 on IIS 7.5 and Discovering a Great Tool (IIS Crypto) Along the Way

TLDR; summary of the fastest way to enable TLS 1.2 on IIS 7.5:

  • Download IIS Crypto at https://www.nartac.com/Products/IISCrypto/
  • Run the executable on your server
  • On the user interface, click the “Best Practices” button (located at bottom left)
  • Click “Apply” (located at bottom right)
  • Reboot Server

The full details:

Today I was contacted by a third-party company that exchanges data with mine and they informed me that they were requiring TLS 1.2 connections as of the new year. Reviewing information about my server’s crypto configuration, I found that, indeed, TLS 1.1 and TLS 1.2 were not enabled.

In setting out to resolve the problem, I ran across a couple of posts that talked about updating registry keys and doing some other messy stuff. And then, I found this post on ServerFault about an awesome tool called IIS Crypto.

From the IIS Crypto website:

IIS Crypto is a free tool that gives administrators the ability to enable or disable protocols, ciphers, hashes and key exchange algorithms on Windows Server 2008, 2012 and 2016. It also lets you reorder SSL/TLS cipher suites offered by IIS, implement best practices with a single click, create custom templates and test your website

Not only is the tool free, it doesn’t even install anything on your machine.

After downloading and running, I looked over the list of available protocols, ciphers, etc. They provide a “Best Practices” button which enables only the protocols, ciphers, etc. that should be enabled using, well, current best practices. This is another awesome feature because the list of everything to review is fairly extensive and not having to do the research myself on these is a huge time saver.

On the program’s menu is a “Site Scanner” tool that will open up a browser and analyze your site. You can use this without running the application. The URL is:

https://www.ssllabs.com/ssltest/analyze.html?d=<your site>&hideResults=on (where <yoursite> is the website you want to analyze)

The analyzer checks your certificate(s), available protocols, and cipher suites, performs handshake simulations with a bevy of operating system / user-agent combinations (well over 50), and analyzes against various attacks. When I first ran the test, the results weren’t so great – there were a number of problems related to my crypto settings.

After reviewing the analyzer, I applied the “Best Practices” settings and restarted the server. Once the server booted back up everything was working and I passed the scanner with flying colors.

For reference, I was working with IIS 7.5 running on Windows Server 2008 R2.