Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

SQL SOUNDEX function

by suresh

The SQL SOUNDEX, one of the String Function, returns the four-digit Soundex code of the user-specified character expressions.

The basic syntax of the SQL Server SOUNDEX Function is as shown below:

SELECT SOUNDEX(Character_Expression)
FROM [Source]

This Soundex function converts any given character’s expression into four-digit code based on the string sound. It will place the first character from the character_expression as the first digit, and the remaining are number. In some cases, it will add 0’s to the end to complete the four-digit code.

SQL SOUNDEX Function Example 1

The following list of examples will help you to understand the Soundex function.

-- SQL Server SOUNDEX Function
DECLARE @Str VARCHAR(50)
SET @Str = 'SQL Server'

SELECT SOUNDEX(@Str) AS SoundText 

SELECT SOUNDEX('SQL') AS SoundText 

SELECT SOUNDEX('Sales') AS SoundText 

SELECT SOUNDEX('Suresh') AS SoundText

OUTPUT

SQL SOUNDEX Function 1

SOUNDEX Example 2

In this example, we are going to return the SOUNDEX code of the multiple character expressions, along with the difference. I suggest you refer to the Difference Function article to understand the same.

-- SQL Server SOUNDEX Function
SELECT SOUNDEX('SQL Server') AS Code1,
       SOUNDEX('SQL') AS Code11,
	   DIFFERENCE('SQL Server', 'SQL') AS Difference1 

SELECT SOUNDEX('SQL') AS Code2,
       SOUNDEX('Suresh') AS Code22,
	   DIFFERENCE('SQL', 'Suresh') AS Difference2

SELECT SOUNDEX('Suresh') AS Code3,
       SOUNDEX('Srsh') AS Code33,
	   DIFFERENCE('Suresh', 'Srsh') AS Difference3

OUTPUT

SQL SOUNDEX Function 2

Placed Under: SQL

Trending Posts

Python Program to find Student Grade

MySQL NOT IN Operator

SQL PERCENTILE_CONT

JavaScript toDateString

MySQL ADDTIME Function

Format Date and Time in SSRS Report

Python Arithmetic Operators

C Program to Reverse a Number

Tableau Bump Chart

Get insights in Power BI

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy