How to Quantify Text Differences in TSQL

How to Quantify Text Differences in TSQL thumbnail
Compare text differences via T-SQL.

TSQL is a set of programming extensions to Structured Query Languages -- or SQL -- including transaction control, exception and error handling, and declared variables. Both Microsoft’s SQL Server and Sybase’s SQL server support T-SQL statements. SQL Server contains a selection of system data types used with the program -- including exact numeric, approximate numeric, data and time, and character strings. Character strings include two data types: char and varchar. T-SQL also has various functions such as Add, Subtract, Multiply, Divide, Break and Difference.

Things You'll Need

  • TSQL
Show More

Instructions

    • 1

      Click “Start,” “All Programs” and “SQL Server Management Studio.” Click one of the databases on the Object Explorer to expand it. Right-click “Tables” and select “New Table.”

    • 2

      Specify the first column as “Item_ID” by entering it in the Column Name field. Select a data type for it such as “int” by clicking the drop-down options on the Data Type field. Create another column name “Item_Name” with “varchar” data type.

    • 3

      Click “File” and “Save Table_1” to save the table. Name the table as “items.” The data insertion interface is prompted. Enter data into the table such as “1” and “Computer” in the first row.

    • 4

      Click “New Query” to enter the query dialog. Enter the following T-SQL statement:
      SELECT DIFFERENCE (Items.Item_Name, “Components”)

    • 5

      Entering the code shown in Step 4 returns an integer value showing the difference between the Soundex values of the two string expressions. In this case, it will return a value of 3. The Soundex function returns a four-character code to assess the similarity of two strings.

Related Searches:

References

  • Photo Credit Ablestock.com/AbleStock.com/Getty Images

Comments

Related Ads

Featured