VARBINARY

  • create table test
    (
    sort_path varbinary(4096),
    );

    insert into test (sort_path) values (0x00000FBA000010D8),(0x00000FBA000010D8000006FB), (0x00000FBA000010D8000006FB00000AA9), (0x00000FBA000010F8)

    Here is some test data using a varbinary.  I want to filter out all rows that start with 0x00000FBA000010D8 (which would be the first 3 rows)

    I've tried:

    select * from test where left(bp.sort_path, DATALENGTH(@CurrentSortPath)) = @CurrentSortPath

    Any ideas?

     

  • LEFT is for character data only.  You need to use SUBSTRING instead.

    ...
    SUBSTRING(bp.sort_path, 1, DATALENGTH(@CurrentSortPath))
    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Perfect thanks, that did the trick!

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

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