Win:

OK, here's a quick way to do it in Perl ... feel free to edit it into shape:

#/usr/bin/perl -w use strict; use warnings; use DBI: my $DBH=DBI->connect("dbi:ODBC:driver={SQL Server};" ."SERVER=XXXX; DATABASE=YYYY;","UID","PWD") or die $DBI::errstr; $DBH->do(qq| DECLARE @Number_of_government_regions INT SET @Number_of_government_regions = (SELECT 354) if exists(select 1 from INFORMATION_SCHEMA.tables where table_name = ' +MyNumbers') DROP TABLE MyNumbers; --MyNumbers --===== Create and populate the Tally table on the fly SELECT TOP 1000 IDENTITY(INT,1,1) AS Nums INTO dbo.MyNumbers FROM Master.dbo.SysColumns sc1, Master.dbo.SysColumns sc2 --===== Add a Primary Key to maximize performance ALTER TABLE dbo.MyNumbers ADD CONSTRAINT PK_MyNumbers_N PRIMARY KEY CLUSTERED (Nums) WITH FILLFACTOR = 100 INSERT INTO Random_region_lookup_table_TEMP (Generation_number, Place +_key) SELECT n.Nums, r.Number_count FROM MyNumbers n CROSS JOIN Region_lookup r WHERE n.Nums <= @Number_of_repeats ORDER BY n.Nums, NEWID() UPDATE Random_region_lookup_table_TEMP SET Place_key = (Place_key)%354 + 1 INSERT INTO Random_region_lookup_table_TEMP (Generation_number, Place_ +key) SELECT n.Nums, r.Number_count FROM MyNumbers n CROSS JOIN Region_lookup r ORDER BY n.Nums, NEWID() |) or die $DBI::errstr;
Heh ... hope this helps!

</snarky_mode>

...roboticus


In reply to Re: Dealing with random subsets by roboticus
in thread Dealing with random subsets by Win

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.