[dba-SQLServer] Building a permanent result table on-the-fly

jwcolby jwcolby at colbyconsulting.com
Wed Jun 20 10:45:56 CDT 2007


When a client asks me to fill an order of names from a name table I end up
with a view that looks something like:

SELECT     TOP (3000) [FName], [LName], [Addr], [City], [ST], [Zip5],
[Zip4], [Zip]
FROM         dbo.tblData
ORDER BY NEWID()

This in fact pulls an apparently random set of names which is good, we like
that.  The problem is that I need to record those names because the client
may come back in a month and say "now give me a DIFFERENT set of names".
Thus I need to know who was pulled last time.  What I need is a way to take
any result set and build a permanent table to hold the results in.  I also
need a way to build a m-m with the PKID of the pulled set and an OrderPK
from an order table (which I am building), but I already know how to do
that.

John W. Colby
Colby Consulting
www.ColbyConsulting.com 




More information about the dba-SQLServer mailing list