Home Forums SQL Server 2008 T-SQL (SS2K8) Efficient way to get the lowest unused value of a nvarchar field being used as a primary key RE: Efficient way to get the lowest unused value of a nvarchar field being used as a primary key

  • micalo (3/21/2014)


    Hi Lempster,

    People can put whatever they want in there unfortunately. There no really way without going through all the data that i can think of. I personally think its bad design but have to work with it unfortunately.

    Regards,

    Michael

    The lowest unused value of an nvarchar column...what characters would you like to take into account?

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden