Difference Function

  • Select * from TableABC where Difference(ColumnABC,'test') = 4

    ColumnABC is of datatype Text

    The Above Stmt Works fine in MS SQL 2000

    but throws an error

    "Argument data type text is invalid for argument 1 of difference function" in MS SQL 7.0

    May i know the solution/workaround for this

  • Select * from TableABC where Difference(cast(ColumnABC as varchar(8000)),'test') = 4

    there are a decent number of tsql functions that fail when fed a column of type text, which means that you've got a maximum of 8000 characters to work with by using varchar(8000) in its place.  if your data is all less than 8000 characters in practice, the above should work, otherwise you can either use:

    Select * from TableABC where Difference(substring(ColumnABC,0,8000)),'test') = 4

    which will grab the first 8000 chars, or just change the datatype of the column and allow the column to be truncated to 8000 chars.  you can also usually write some sort of loop to chunk through the contents of a text field, but in this case i doubt that would work for you since the soundex/difference functions seem like the sort of functions that work on a whole string...

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply