Re: Mailing to users

Dale E. Reed Jr. ( (no email) )
Thu, 14 May 1998 19:22:07 -0700

Michael Whisenant wrote:
> I would like to create a script that parses all sub accounts by region so
> that I can mass e-mail those users information that might impact their
> situation. I have tried network status pages, phone mail call directors,
> mass e-mail to all users and feel a targeted approach would be the easiest
> method. I could organize the users by region into a mailing list on the
> fly, yet I have problems getting them out of the database for some reason.
> Since the tables are not indexed, the query will take some time, I do not
> mind the wait, yet I am getting various messages. The one that happens
> almost everytime now is attached.

Actually, time should still be seconds for this kind of query.

> Select ma.Region, sa.Login
> From MasterAccounts ma, SubAccounts sa
> Where ma.Region = 'xxxxxx'
> Order by sa.Login, ma.Region
> Go

The reason you are running out of space, if you haven't linked the
masteraccounts and subaccounts table. Therefore, SQL Server is giving
you the cartesian results of all possible combinations. If you have
5000 MBRs and 5000 subaccounts, that would be 5000*5000 which would
result in 25 million records returned. :)

So just add the ma.CustomerID = sa.CustomerID to the where
clause and all should be fine.

> Msg 1105, Level 17, State 1
> Can't allocate space for object '-1250' in database 'tempdb' because the
> 'system' segment is full. If you ran out of space in Syslogs, dump the
> transaction log. Otherwise, use ALTER DATABASE or sp_extendsegment to
> increase the size of the segment.
> Msg 1510, Level 17, State 2
> Sort failed: Out of space or locks in database 'tempdb'

-- Dale E. Reed Jr.  (       IEA Software, Inc.      |  RadiusNT, Emerald, and NT FAQs Internet Solutions for Today  |