• a quick bump on an old post. i just needed to generate some random strings, and had this saved in my snippets. when i tested it, it didn't work, it returned the same string 100x times, and there's a comment that explicitly says there's an attempt to trick the optimizer.

    the "case when Num >= 0 then 8 else 8 end,16," trick mentioned to fool the optimizer does not work on SQL2012 or SQL2014;

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!