Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For a moment, forget your issue with what must be an attempt to insert into a linked server (though it is not obvious from your code that <code>Customers</code> must either be a synonym or you dumbed the statement down).</p> <p>Ask yourself: why would you use random numbers for uniqueness? Random and unique may seem like similar concepts, but they're not. </p> <p>I also see a lack of error handling (again, this may just be that you dumbed down your code to "help" us). Eventually you will get duplicates. You may want to read <a href="http://www.mssqltips.com/sqlservertip/3055/generating-random-numbers-in-sql-server-without-collisions/" rel="nofollow">this tip</a> and <a href="http://www.sqlperformance.com/2013/09/t-sql-queries/random-collisions" rel="nofollow">this blog post</a>. Essentially, as you insert more and more "unique" values, the likelihood that you will get a collision increases. So rather than solve the issue with your solution, I think you should step back and re-consider the problem.</p> <p>Why are you using random numbers instead of simpler concepts that - at least by default - help assure uniqueness in a much more predictable way, like <code>IDENTITY</code> or <code>SEQUENCE</code>? Is it to prevent people from guessing the next value, or being able to determine how many values you generate in a time period? If so, then pre-populate a table with a bunch of random values, and pull one off the stack when you need one, <a href="http://www.sqlperformance.com/2013/09/t-sql-queries/random-collisions" rel="nofollow">as I described here</a>. If this isn't the crucial issue, then stop breaking your back and just use an existing methodology for generating unique - and not random - numbers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload