jwcolby
jwcolby at colbyconsulting.com
Mon Mar 24 10:55:43 CDT 2008
It has to be permanent random number. I have to select the top N records but they have to be random records within the table. I also have to date stamp the records selected to indicate that they have been selected and on which date. The way I normally attack this is to create a random int field and a SelectedDate field, and populate the random int field. I then update the top N date field (sorted by random int field where date = null). I then select those with today's data and ship them out, but ordered by Zip / +4. Mailing label orders. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Paul Nielsen Sent: Monday, March 24, 2008 10:52 AM To: 'Discussion concerning MS SQL Server' Subject: Re: [dba-SQLServer] SQL to create Integer Random John, It is important that random number for the row is permanent? Or is the intention that you're able to randomly select row? -Paul -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Monday, March 24, 2008 10:37 AM To: 'Discussion concerning MS SQL Server' Subject: [dba-SQLServer] SQL to create Integer Random I need to create a field that is an integer, and which is then filled with a random number when the rows are populated. In Access you could set up an autonumber with random. Is it possible to do something like this in SQL Server? If now can I do a function in an aliased field, where that random number is then inserted into the integer field? John W. Colby Colby Consulting www.ColbyConsulting.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com __________ NOD32 2968 (20080324) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com