IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

Format SQL Using Redgate SQL Prompt

As a follow-up of the post String Literals as Column Aliases are Deprecated, this one feature from Redgate’s SQL Prompt is quite handy to correct any existing SQL scripts quickly.

Using the SQL from How to Find All References to an Object in a SQL Server Database as an example, here’s what we originally have:

SELECT DISTINCT OBJECT_NAME(m.object_id) AS 'object name', m.*
FROM sys.sql_modules m
WHERE m.definition LIKE '%Customer_Name%'

Pay attention to the object name within the single quotes as a column alias.

If this is only a one-off such as this one, it’s no sweat to fix it manually, but what happens if you have a long query with multiple lines of column aliases that you want to fix?

If you have Redgate SQL Prompt, you just need to set it once in the Options as shown below:

  1. In SSMS, go to SQL Prompt on the top menu, and select Options.

    Redgate SQL Prompt Options from SSMS menu

  2. In the Options window, go to Format, Styles. Under Actions, check Apply column alias style and select column AS “alias”, then click OK.

    Redgate SQL Prompt Format Styles column as alias

You’re done with the configuration.

How do you use it?

The best way to use it is by using a keyboard shortcut.

If you click on the SQL Prompt from the menu again, you’ll see an option for Format SQL with a shortcut CTRL+K, CTRL+Y.

Redgate SQL Prompt Options from SSMS menu

In your query window where you have the SQL you want to fix, just use the keyboard shortcut (or you can do that from the menu as well) and right away, it will reformat the query with the fix:

SELECT DISTINCT
       OBJECT_NAME(m.object_id) AS "object name",
       m.*
FROM sys.sql_modules m
WHERE m.definition LIKE '%Customer_Name%';

This is one of the useful features in SQL Prompt to make your life easier. If you notice from the screenshots above, the top bar also has a red color to indicate that it is a production database. It’s a nice way to color code different database environment that can also be configured in SQL Prompt.

Further Reading

How to Use Custom Color in SSMS Using Redgate SQL Prompt

Download

Redgate SQL Prompt (FREE Trial)

December 14, 2022 Filed Under: How To Tagged With: Microsoft SQL Server, SQL, SQL Server

How to Install a Certificate on Windows Server

Steps to Install a Certificate on a Window Server

  1. Right-click on Windows button at the bottom left corner and select Run.

  2. Type in mmc and click OK.

    Run MMC from Windows Run

  3. On the new Console window menu, click on file and select Add/Remove Snap-in… or press Ctrl+M.

  4. Select Certificates and click on Add > button. Select Computer account and click Next.

  5. Click on Local computer and click Finish. You should see Certificates (Local Computer) on the Selected snap-ins: pane. click OK.

    Add Certificates Snap-ins

  6. Under the Console Root on the left pane, expand on Personal, Certificates.

    Certificates import - All Tasks

  7. Import the certificate (pfx file) from Local Machine and click Next.

  8. Select the certificate file from the local folder and click Next.

    Certificate import wizard - pfx file

  9. Type in the password for the certificate and check on Include all extended properties and click Next.

    Certificate import wizard - certificate password

  10. Check on Place all certificates in the following store – Certificate store: and type in Personal if it’s not already filled in. Click Next.

  11. The Certificate Import Wizard will confirm all the selection. If everything is correct, just click on Finish and you should get a confirmation that the import was successful. Click OK and you’re done.

Please keep in mind if you’re installing this certificate for a website on IIS, you still need to assign the certificate to the corresponding website on IIS.

Further Reading

Installing the trusted root certificate

December 12, 2022 Filed Under: How To Tagged With: Microsoft, Windows Server

How to Serve AVIF Image Format with Fallback for Other Browsers

AVIF is a modern image format based on the AV1 video format and generally has better compression than WebP, JPEG, PNG and GIF. This format is designed to supersede them. Unfortunately, the support for AVIF in web browsers is still not as high as it is for WebP format.

Can I Use AVIF Browser Support

So if we want to use AVIF on our website, it is wise to also provide an easy fallback for other browsers.

The easiest method to do is by using element as follow:

<picture>
  <source srcset="images/logo.avif" type="image/avif">
  <img src="images/logo.png" id="logo" alt="IT Nota Logo example">
</picture>

That’s all there is to it. You can check which image is loaded using your browser developer tools.

If you use an IIS server, you need to add this new image type into the MIME Type before you can serve AVIF format on your page.

Further Reading

How to Serve AVIF Image on IIS
How to Serve WebP Image Format with Fallback for Other Browsers
How to Serve WebP Image on IIS

December 5, 2022 Filed Under: How To Tagged With: HTML5

How to Serve AVIF Image on IIS

How do you take advantage of serving AVIF image from IIS server? For simplicity sake, since the setup is very similar to serving WebP format, I’m going to use the same screenshot illustrations from that post.

The problem with using IIS Server is by default IIS does not recognize AVIF as an image type so it cannot correctly render it on the page even if the browser can support it.

Using a test page avif-test.html with the content below, the page will render as shown.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>IT Nota AVIF Test Render</title>
</head>
<body>
  <h1>PNG</h1>
  <img src="images/caniuse-AVIF-Test.png" width="368" height="335" alt="PNG" />

  <h1>AVIF</h1>
  <img src="images/caniuse-AVIF-Test.avif" width="368" height="335" alt="AVIF" />
</body>
</html>

IIS failed to render WebP format
The screenshot above is taken from a webp test page, however the experience will be very similar for AVIF.

The issue stems from the fact that IIS does not recognize AVIF as a legitimate MIME type. So with a simple fix, we can make IIS to treat the new format as a valid image file.

How to Enable AVIF on IIS

  1. Launch IIS Manager.

  2. Click on your main server on the left pane to make sure we’re making the change on a server level (as opposed to a site level). Then click on the MIME Types.

    IIS Manager MIME type setting

  3. On the right pane of MIME Types dialog box, click on Add… link.

    IIS Manager Add a new MIME Type

  4. We want to add a new MIME type of AVIF as an image type so IIS knows how to handle this new format.

    In Add MIME Type box, enter .avif as the file name extension and image/avif as the MIME type and click OK.

    IIS Manager add new MIME type AVIF as image/avif

That’s all there is to it.

Now if you reload your Chrome browser, you should be able to see both image files rendered correctly.

WebP rendered from IIS successfully
The screenshot above is taken from a webp test page, however the experience will be very similar for AVIF.

As a side note, currently, the way to compress the image to AVIF is to do it from avif.io website.

Further Reading

How to Serve AVIF Image Format with Fallback for Other Browsers
How to Serve WebP Image on IIS
How to Serve WebP Image Format with Fallback for Other Browsers
How to Serve Outlook File Type on IIS

December 2, 2022 Filed Under: How To Tagged With: IIS, Internet Information Services, Microsoft

How to Change the Time Stamp of a File Using PowerShell

From time to time, you may need to modify the time stamp of a file for archiving or any other reasons.

This PowerShell script comes in handy when you need to do it. This is for a one-off tweak of a file. If you’re doing this in bulk, it’s probably better to use Robocopy with a /copy:T option (see an example here) to copy all the attributes including the time stamp.

PowerShell script to change the timestamp for a file

(Get-Item "C:\Temp\ITNota.txt").LastWriteTime=("6/1/2022 15:00:00")

Or

(Get-Item "C:\Temp\ITNota.txt").LastWriteTime=("1 June 2022 15:00:00")

Two versions of the script were provided to eliminate ambiguity of the date system. You just need to use one of them.

If you use the US date format, the first one will work. Otherwise, it’s always safer to spell out the date and the month.

Further Reading

How to Change File Date or Timestamp in Windows

July 20, 2022 Filed Under: How To Tagged With: PowerShell, Windows, Windows Server

« Previous Page
Next Page »
Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure