Code Monkey home page Code Monkey logo

Comments (2)

richardtallent avatar richardtallent commented on September 26, 2024

Hi Pál,

I'm glad to hear it!

To test, you can look for GUIDs outside your expected date range:

SELECT * FROM myTable WHERE 
guid < SELECT CAST(
    CAST(DATEDIFF_BIG(MILLISECOND, '1970-1-1', '2015-01-22') AS BINARY(16))
    AS UNIQUEIDENTIFIER)
OR guid > SET @startGuid = SELECT CAST(
    CAST(DATEDIFF_BIG(MILLISECOND, '1970-1-1', GETUTCDATE()) AS BINARY(16))
    AS UNIQUEIDENTIFIER);

The above code assumes that you started using COMBs on 2015-01-22 and that you are using the UnixTimeStampStrategy with SqlCombProvider on MSSQL 2016+ or Azure DB. The same approach can be used with the other strategies or database platforms.

This is not foolproof -- there is a small but real chance that a random non-COMB GUID may have a "valid" COMB date/time. If you have other data you can compare to -- for example, an audit log of when the record was inserted -- you could look for a smaller valid date range.

I'm looking at doing the same thing with some legacy data. In my case, the GUIDs were created using the original SqlDateTimeStrategy and I've now standardized my code to use the UnixTimeStampStrategy. So in my case I'll be looking for GUIDs outside the acceptable Unix date range but within the SQL DateTime range, extracting the timestamp, and re-creating the equivalent Unix timestamp GUID. I haven't written the code for that yet, but it'll be similar to the above. Fortunately, none of the GUIDs in my case are used as foreign keys, so this should be a fairly simple process.

from rt.comb.

pethopal avatar pethopal commented on September 26, 2024

Hi Richard,
thanks for the check code, info!

from rt.comb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.