Updating a Counter

  • I'd like to use a DTS task to move data from a SQL Server 2K db to a Btrieve (6.15) data file.  The key to the Btrieve file is ID# - Counter, where Counter is the next number in sequence for that ID#.  So the relevant data in the SQL table may look like this:  127, 127, 127, 128, 129, 129

    and the resulting Btrieve data will need to look like this:  127-1, 127-2, 127-3, 128-66 (assuming 65 previous records in the file for that ID#), 129-15, 129-16.

    Now I haven't begun to figure out how to do this in DTS yet, but putting that aside for the moment, here's my question.  Is there a set-based solution for this, or am I going to have to use a cursor?

    Thanks,

    Mattie

  • If you know the format is always going to be -, yes, you can do it in a set-based way. You could do something along the lines of:

    WHERE MyNumber = SUBSTRING(MyID, 1, CHARINDEX('-', MyID, 1) - 1)

    K. Brian Kelley
    @kbriankelley

  • Thanks for your reply.  However, if I understand your answer correctly, I didn't ask my question very well.  I don't need to find 'MyNumber', I need to compute it.

    Mattie

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

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