Showing posts with label idea. Show all posts
Showing posts with label idea. Show all posts

Thursday, March 29, 2012

determine the assigned identity range

Is there any way to find out a subscriber's assigned identity range (at the
publisher)?
It would be helpful to have an idea where a row was added from its identity
value.
No, it only maintains the last range assigned - which will be the highest
one.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
<tedcorpus@.hotmail.com> wrote in message
news:%23F7cc61eFHA.412@.tk2msftngp13.phx.gbl...
> Is there any way to find out a subscriber's assigned identity range (at
the
> publisher)?
> It would be helpful to have an idea where a row was added from its
identity
> value.
>
|||In the distribution database, MSrepl_identity_range holds the next ranges,
so You'll have to work with the metadata tables on the subscribers for this:
You could use this type of query:
SELECT sysobjects.name AS TableName, *
FROM MSrepl_identity_range INNER JOIN
sysobjects ON MSrepl_identity_range.objid =
sysobjects.id
The data from each subscriber could be amalgamated at the publisher using
linked servers,
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Thanks!
So I could compare max_identity/current_max columns across servers
(accounting for the range value). But linking the servers just for this
purpose might be more administration work than benefit at this point.
"Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
news:ehDGtl7eFHA.2076@.TK2MSFTNGP15.phx.gbl...
> In the distribution database, MSrepl_identity_range holds the next ranges,
> so You'll have to work with the metadata tables on the subscribers for
> this:
> You could use this type of query:
> SELECT sysobjects.name AS TableName, *
> FROM MSrepl_identity_range INNER JOIN
> sysobjects ON MSrepl_identity_range.objid =
> sysobjects.id
> The data from each subscriber could be amalgamated at the publisher using
> linked servers,
> Rgds,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>
|||You only need to look at the max value on the publisher's distribution
database. That will be the next assigned range.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"TCorp" <tcorpus@.hotmail.com> wrote in message
news:eg1MgYagFHA.2548@.TK2MSFTNGP10.phx.gbl...[vbcol=seagreen]
> Thanks!
> So I could compare max_identity/current_max columns across servers
> (accounting for the range value). But linking the servers just for this
> purpose might be more administration work than benefit at this point.
> "Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
> news:ehDGtl7eFHA.2076@.TK2MSFTNGP15.phx.gbl...
ranges,[vbcol=seagreen]
using
>

Determine table names and column names at runtime?

Hi

I was wondering if anyone has an idea of how we could find the table names and column names of the tables in our Sql server database at runtime/dynamically given our connection string? Please let me know.

Thanks.The only advice I can give is this: All your database's objects are stored in the sysobjects table. And then there's syscolumns and sysindexes (shouldn't that be sysindices?).

I would be suprised if there were not free libraries out there that make it easy to get information about sql objects. I don't know of one particularly. Anyone know of one? If not, that might make a cool community project.|||There is a stored procedure sp_tables that returns a list of tables.

There is a stored procedure sp_columns that returns a list of Columns.

These are better to use than the system tables, as they are documented and should not change in a way to break your code. Look them up in Books Online...|||Gravy!

Glad you're here.|||> There is a stored procedure sp_tables that returns a list of tables.

ah, forgot about that. I guess because I usually only use it to do an

IF EXISTS (SELECT name FROM sysobjects WHERE name = 'whatever')

and an SP is no good there.... cheers for reminding me.|||In that case, you could/should use:


IF EXISTS (SELECT table_name FROM INFORMATION_SCHEMA.tables WHERE table_name = 'whatever')

Terri

Friday, March 9, 2012

Detach - Attach in SQL Server 7

How do I detach and attach a database in SQL Server 7? The idea is to erase
the humongous log file and this is how I do it in 2000.
Hi,
It is not rquired to detach and attach the database to shrink the file.
Follow the below steps:-
1. backup the Transaction log
Backup log <dbname> to disk='d:\backup\dbname.trn'
2. If the log file really huge make the databse single user after removing
all users connected to database
sp_dboption 'dbname','sinle user',true -- for SQL 2000 you could use
ALTER DATABASE <dbname> set single_user with rollback immediate
3. Shrink the Transaction log file
DBCC SHRINKFILE('Logical_ldf_name','truncateonly'
4. After this see the log size by using
DBCC SQLPERF(LOGSPACE)
5. Now turn back the database to multi user
sp_dboption 'dbname','sinle user',false -- for SQL 2000 you could use
ALTER DATABASE <dbname> set multi_user
Thanks
Hari
MCDBA
"Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
news:#GmetWBaEHA.4092@.TK2MSFTNGP11.phx.gbl...
> How do I detach and attach a database in SQL Server 7? The idea is to
erase
> the humongous log file and this is how I do it in 2000.
>
|||Doesn't this only truncate the file though? It really won't make much of a
difference. The reason I asked for a way to detach - attach is because this
way I can start with a brand new log file thus freeing 4GB in my hard drive.
"Hari Prasad" <hari_prasad_k@.hotmail.com> escribi en el mensaje
news:efrkEcBaEHA.4048@.TK2MSFTNGP10.phx.gbl...
> Hi,
> It is not rquired to detach and attach the database to shrink the file.
> Follow the below steps:-
> 1. backup the Transaction log
> Backup log <dbname> to disk='d:\backup\dbname.trn'
> 2. If the log file really huge make the databse single user after removing
> all users connected to database
> sp_dboption 'dbname','sinle user',true -- for SQL 2000 you could use
> ALTER DATABASE <dbname> set single_user with rollback immediate
> 3. Shrink the Transaction log file
> DBCC SHRINKFILE('Logical_ldf_name','truncateonly'
>
> 4. After this see the log size by using
> DBCC SQLPERF(LOGSPACE)
> 5. Now turn back the database to multi user
> sp_dboption 'dbname','sinle user',false -- for SQL 2000 you could use
> ALTER DATABASE <dbname> set multi_user
> Thanks
> Hari
> MCDBA
> "Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
> news:#GmetWBaEHA.4092@.TK2MSFTNGP11.phx.gbl...
> erase
>
|||Hi,
Can you go thru this article and try shrinking the LDF file based on steps
mentioned.
http://www.support.microsoft.com/?id=256650
Thanks
Hari
MCDBA
"Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
news:OmZtgzBaEHA.212@.TK2MSFTNGP12.phx.gbl...
> Doesn't this only truncate the file though? It really won't make much of a
> difference. The reason I asked for a way to detach - attach is because
this
> way I can start with a brand new log file thus freeing 4GB in my hard
drive.[vbcol=seagreen]
> "Hari Prasad" <hari_prasad_k@.hotmail.com> escribi en el mensaje
> news:efrkEcBaEHA.4048@.TK2MSFTNGP10.phx.gbl...
removing[vbcol=seagreen]
use
>

Detach - Attach in SQL Server 7

How do I detach and attach a database in SQL Server 7? The idea is to erase
the humongous log file and this is how I do it in 2000.Hi,
It is not rquired to detach and attach the database to shrink the file.
Follow the below steps:-
1. backup the Transaction log
Backup log <dbname> to disk='d:\backup\dbname.trn'
2. If the log file really huge make the databse single user after removing
all users connected to database
sp_dboption 'dbname','sinle user',true -- for SQL 2000 you could use
ALTER DATABASE <dbname> set single_user with rollback immediate
3. Shrink the Transaction log file
DBCC SHRINKFILE('Logical_ldf_name','truncateonly'
4. After this see the log size by using
DBCC SQLPERF(LOGSPACE)
5. Now turn back the database to multi user
sp_dboption 'dbname','sinle user',false -- for SQL 2000 you could use
ALTER DATABASE <dbname> set multi_user
Thanks
Hari
MCDBA
"Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
news:#GmetWBaEHA.4092@.TK2MSFTNGP11.phx.gbl...
> How do I detach and attach a database in SQL Server 7? The idea is to
erase
> the humongous log file and this is how I do it in 2000.
>|||Doesn't this only truncate the file though? It really won't make much of a
difference. The reason I asked for a way to detach - attach is because this
way I can start with a brand new log file thus freeing 4GB in my hard drive.
"Hari Prasad" <hari_prasad_k@.hotmail.com> escribió en el mensaje
news:efrkEcBaEHA.4048@.TK2MSFTNGP10.phx.gbl...
> Hi,
> It is not rquired to detach and attach the database to shrink the file.
> Follow the below steps:-
> 1. backup the Transaction log
> Backup log <dbname> to disk='d:\backup\dbname.trn'
> 2. If the log file really huge make the databse single user after removing
> all users connected to database
> sp_dboption 'dbname','sinle user',true -- for SQL 2000 you could use
> ALTER DATABASE <dbname> set single_user with rollback immediate
> 3. Shrink the Transaction log file
> DBCC SHRINKFILE('Logical_ldf_name','truncateonly'
>
> 4. After this see the log size by using
> DBCC SQLPERF(LOGSPACE)
> 5. Now turn back the database to multi user
> sp_dboption 'dbname','sinle user',false -- for SQL 2000 you could use
> ALTER DATABASE <dbname> set multi_user
> Thanks
> Hari
> MCDBA
> "Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
> news:#GmetWBaEHA.4092@.TK2MSFTNGP11.phx.gbl...
> > How do I detach and attach a database in SQL Server 7? The idea is to
> erase
> > the humongous log file and this is how I do it in 2000.
> >
> >
>|||Hi,
Can you go thru this article and try shrinking the LDF file based on steps
mentioned.
http://www.support.microsoft.com/?id=256650
--
Thanks
Hari
MCDBA
"Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
news:OmZtgzBaEHA.212@.TK2MSFTNGP12.phx.gbl...
> Doesn't this only truncate the file though? It really won't make much of a
> difference. The reason I asked for a way to detach - attach is because
this
> way I can start with a brand new log file thus freeing 4GB in my hard
drive.
> "Hari Prasad" <hari_prasad_k@.hotmail.com> escribió en el mensaje
> news:efrkEcBaEHA.4048@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > It is not rquired to detach and attach the database to shrink the file.
> > Follow the below steps:-
> >
> > 1. backup the Transaction log
> >
> > Backup log <dbname> to disk='d:\backup\dbname.trn'
> >
> > 2. If the log file really huge make the databse single user after
removing
> > all users connected to database
> >
> > sp_dboption 'dbname','sinle user',true -- for SQL 2000 you could
use
> > ALTER DATABASE <dbname> set single_user with rollback immediate
> >
> > 3. Shrink the Transaction log file
> >
> > DBCC SHRINKFILE('Logical_ldf_name','truncateonly'
> >
> >
> > 4. After this see the log size by using
> >
> > DBCC SQLPERF(LOGSPACE)
> >
> > 5. Now turn back the database to multi user
> >
> > sp_dboption 'dbname','sinle user',false -- for SQL 2000 you could use
> > ALTER DATABASE <dbname> set multi_user
> >
> > Thanks
> > Hari
> > MCDBA
> >
> > "Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
> > news:#GmetWBaEHA.4092@.TK2MSFTNGP11.phx.gbl...
> > > How do I detach and attach a database in SQL Server 7? The idea is to
> > erase
> > > the humongous log file and this is how I do it in 2000.
> > >
> > >
> >
> >
>

Detach - Attach in SQL Server 7

How do I detach and attach a database in SQL Server 7? The idea is to erase
the humongous log file and this is how I do it in 2000.Hi,
It is not rquired to detach and attach the database to shrink the file.
Follow the below steps:-
1. backup the Transaction log
Backup log <dbname> to disk='d:\backup\dbname.trn'
2. If the log file really huge make the databse single user after removing
all users connected to database
sp_dboption 'dbname','sinle user',true -- for SQL 2000 you could use
ALTER DATABASE <dbname> set single_user with rollback immediate
3. Shrink the Transaction log file
DBCC SHRINKFILE('Logical_ldf_name','truncateo
nly'
4. After this see the log size by using
DBCC SQLPERF(LOGSPACE)
5. Now turn back the database to multi user
sp_dboption 'dbname','sinle user',false -- for SQL 2000 you could use
ALTER DATABASE <dbname> set multi_user
Thanks
Hari
MCDBA
"Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
news:#GmetWBaEHA.4092@.TK2MSFTNGP11.phx.gbl...
> How do I detach and attach a database in SQL Server 7? The idea is to
erase
> the humongous log file and this is how I do it in 2000.
>|||Doesn't this only truncate the file though? It really won't make much of a
difference. The reason I asked for a way to detach - attach is because this
way I can start with a brand new log file thus freeing 4GB in my hard drive.
"Hari Prasad" <hari_prasad_k@.hotmail.com> escribi en el mensaje
news:efrkEcBaEHA.4048@.TK2MSFTNGP10.phx.gbl...
> Hi,
> It is not rquired to detach and attach the database to shrink the file.
> Follow the below steps:-
> 1. backup the Transaction log
> Backup log <dbname> to disk='d:\backup\dbname.trn'
> 2. If the log file really huge make the databse single user after removing
> all users connected to database
> sp_dboption 'dbname','sinle user',true -- for SQL 2000 you could use
> ALTER DATABASE <dbname> set single_user with rollback immediate
> 3. Shrink the Transaction log file
> DBCC SHRINKFILE('Logical_ldf_name','truncateo
nly'
>
> 4. After this see the log size by using
> DBCC SQLPERF(LOGSPACE)
> 5. Now turn back the database to multi user
> sp_dboption 'dbname','sinle user',false -- for SQL 2000 you could use
> ALTER DATABASE <dbname> set multi_user
> Thanks
> Hari
> MCDBA
> "Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
> news:#GmetWBaEHA.4092@.TK2MSFTNGP11.phx.gbl...
> erase
>|||Hi,
Can you go thru this article and try shrinking the LDF file based on steps
mentioned.
http://www.support.microsoft.com/?id=256650
Thanks
Hari
MCDBA
"Sergio Florez M." <sergioflorezm@.hotmail.com> wrote in message
news:OmZtgzBaEHA.212@.TK2MSFTNGP12.phx.gbl...
> Doesn't this only truncate the file though? It really won't make much of a
> difference. The reason I asked for a way to detach - attach is because
this
> way I can start with a brand new log file thus freeing 4GB in my hard
drive.
> "Hari Prasad" <hari_prasad_k@.hotmail.com> escribi en el mensaje
> news:efrkEcBaEHA.4048@.TK2MSFTNGP10.phx.gbl...
removing[vbcol=seagreen]
use[vbcol=seagreen]
>

Sunday, February 19, 2012

Design question - Foreign key indexes

A rather elementary design question - is it a good idea to index foreign keys in fact tables? I understand this will slow down inserts/deletes/updates, but when the cube is processing will it speed up processing time? Does the cube generate all dimension members then query fact tables for them? Does it query fact tables with group by's on participating dimensions? I see example cubes that have this, but am unable to find documentation saying this is a good idea. I would hate to miss out on a big performance boost, but don't want to take the chance to slow things down... Any suggestions / supporting documentation is very much welcomed.

Thanks in advance,

John Hennesey

It is an interesting question.

General assumption is Analysis Services cubes are being built based on the relational data warehouse which data is coming from OLTP system. The relationa data warehouse is not the place where you expecting lots of individual atomic updates. That is in theory. In practice depending on the size I have seen implmentations where cubes are built based on raw OLTP shemas.

It is dependant on your case and it is really tradeoff you will be making. If you would like to speed up processind of cubes , you should go and run, for example index tuning wizard and build your relational database indexes that match the queries Analysis Server sends during processing. I wouldnt go and try analyzing every query by yourself. Index tuning wizard makes work easier for you.

But if you see indexed built slowing down your ETL update process, you can always drop these indexes.

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||

Hi:

I think there is another consideration and it is performance -not on insertion of data - but at ETL time, when you want to determine if a given row is already present in a dimension (locating a row).

Most of the times, I just index for ETL speed. OLAP Processing , because of the amount of rows read, may easily go to be a table/partition scan, making indexes almost useless.However, that also depends on the cardinality of your attributes, and what kind of processing you use in your OLAP structures

Alejandro Leguizamo

SQL Server MVP

Colombia

|||

Alejandro / Edward -

Thank you very much for your quick responses - both very good points. Edward - to clarify, we are using service broker which receives xml messages from our source system, which uses stored procs to update our data warehouse. During peak times we receive hundreds of thousands of messages each day, and each one will cause updates / inserts / deletes in our dimension and fact tables. Hence my consideration about index changes slowing things down. When we process, we are doing a full process, so Alejandro's response about doing full table scans is a very realistic possibility. The only way to truly tell what is going on and if there can be some performance boost is to run the index tuning wizard - a very good suggestion. I will check it out!

Thanks again,

John

p.s. Alejandro - you would be suprised what the Enterprise Reporting solution has evolved into - I believe Robert Skoglund gave you guys a nice presentation a few months back...

Friday, February 17, 2012

Design issue

Anybody have an idea on this.
I currently have a DB with 2 tables.
TableUser
TableInfo
With fields like:
TableUser = UserID, Name, Phone
TableInfo = UserID, comments, status
The user table has the users main info, the info table has some other misc.
info.
I need a way for each user to have a different set of custom fields that
links to the info table.
So I was thinking about adding 2 new tables named TableCustomFields and
TableCustomData.
The TableCustomField would hold the specific users custom fields and have
fields like
CustID
UserID This would link to the induividual user
FieldName This would be the custom field name
DataID This would link to the tableCustomData with the actual data for the
field
The TableCustomData would hold the data for that custom field and have
fields like
CustID This field would link to the field name row
InfoID This filed would link to the info table row
Data This would be the actual data in the custom field
Does this sound right to anybody, or is there a better way to accomplish
what I'm looking for.
I have to keep in mind that I will need to be able to get a users info
table data along with their custom fields and data and display it all in a
row as effieciently as possible.
Thanks for any help
Hi,
Since this is a consultation type issue, you can contact Advisory Services
(AS) . Microsoft Advisory Services provides short-term advice and guidance
for problems not covered by Problem Resolution Service as well as requests
for consultative assistance for design, development and deployment issues.
You may call this number to get Advisory Services: (800) 936-5200.
It is hard to say which design will be the best practise for your sceanrio.
You may also combine FieldName and FieldValue in one table in case you need
the query faster and the volumn of Filed is not so high.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.

Design issue

Anybody have an idea on this.
I currently have a DB with 2 tables.
TableUser
TableInfo
With fields like:
TableUser = UserID, Name, Phone
TableInfo = UserID, comments, status
The user table has the users main info, the info table has some other misc.
info.
I need a way for each user to have a different set of custom fields that
links to the info table.
So I was thinking about adding 2 new tables named TableCustomFields and
TableCustomData.
The TableCustomField would hold the specific users custom fields and have
fields like
CustID
UserID This would link to the induividual user
FieldName This would be the custom field name
DataID This would link to the tableCustomData with the actual data for the
field
The TableCustomData would hold the data for that custom field and have
fields like
CustID This field would link to the field name row
InfoID This filed would link to the info table row
Data This would be the actual data in the custom field
Does this sound right to anybody, or is there a better way to accomplish
what I'm looking for.
I have to keep in mind that I will need to be able to get a users info
table data along with their custom fields and data and display it all in a
row as effieciently as possible.
Thanks for any helpHi,
Since this is a consultation type issue, you can contact Advisory Services
(AS) . Microsoft Advisory Services provides short-term advice and guidance
for problems not covered by Problem Resolution Service as well as requests
for consultative assistance for design, development and deployment issues.
You may call this number to get Advisory Services: (800) 936-5200.
It is hard to say which design will be the best practise for your sceanrio.
You may also combine FieldName and FieldValue in one table in case you need
the query faster and the volumn of Filed is not so high.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

Design issue

Anybody have an idea on this.
I currently have a DB with 2 tables.
TableUser
TableInfo
With fields like:
TableUser = UserID, Name, Phone
TableInfo = UserID, comments, status
The user table has the users main info, the info table has some other misc.
info.
I need a way for each user to have a different set of custom fields that
links to the info table.
So I was thinking about adding 2 new tables named TableCustomFields and
TableCustomData.
The TableCustomField would hold the specific users custom fields and have
fields like
CustID
UserID This would link to the induividual user
FieldName This would be the custom field name
DataID This would link to the tableCustomData with the actual data for the
field
The TableCustomData would hold the data for that custom field and have
fields like
CustID This field would link to the field name row
InfoID This filed would link to the info table row
Data This would be the actual data in the custom field
Does this sound right to anybody, or is there a better way to accomplish
what I'm looking for.
I have to keep in mind that I will need to be able to get a users info
table data along with their custom fields and data and display it all in a
row as effieciently as possible.
Thanks for any helpHi,
Since this is a consultation type issue, you can contact Advisory Services
(AS) . Microsoft Advisory Services provides short-term advice and guidance
for problems not covered by Problem Resolution Service as well as requests
for consultative assistance for design, development and deployment issues.
You may call this number to get Advisory Services: (800) 936-5200.
It is hard to say which design will be the best practise for your sceanrio.
You may also combine FieldName and FieldValue in one table in case you need
the query faster and the volumn of Filed is not so high.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Design idea Help for Database

we are creating a database of sales agents. Basically I have a table
of about 35,000 people, a second one with 8000 offices, and a third
table of around 400,000 transactions done by those 35,000 people in
those 8000 offices. We get new data everyday that just updates the
existing tables with the updated rosters and transactions.

I want to build a quick website where our recruiters can look up those
people and keep contact info and all that fun stuff but also pull
numbers on those people. Like

* How Many Transactions that Sales Agent did last year
* Rosters by office showing production

The goal is to click the users name and see all the percentages,
commissions and data like that which we will get by searching that
table of transactions by the agents ID.

the problems I see right away are stuff like
* If I were to pull a report showing all agents in a single office with
their number of transactions next to their name, that is a HUGE query.
It would have to search the 400k worth of records for each of the
agents on just that one report.

A suggestions I was given
I was told by a fellow programmer a better way to do this is to have an
additional table that houses stats info and have the SQL server run
automated reports everyday at say midnight where it updates that table.
This table could show stuff like
** number of transactions for each user
** avg sales price on all transactions for each user
** avg commission on transaction for each user

let me know your thoughts

thanks in advance
Monkey Girlbob1barker@.yahoo.com wrote:

> we are creating a database of sales agents. Basically I have a table
> of about 35,000 people, a second one with 8000 offices, and a third
> table of around 400,000 transactions done by those 35,000 people in
> those 8000 offices. We get new data everyday that just updates the
> existing tables with the updated rosters and transactions.
> I want to build a quick website where our recruiters can look up those
> people and keep contact info and all that fun stuff but also pull
> numbers on those people. Like
> * How Many Transactions that Sales Agent did last year
> * Rosters by office showing production
> The goal is to click the users name and see all the percentages,
> commissions and data like that which we will get by searching that
> table of transactions by the agents ID.
> the problems I see right away are stuff like
> * If I were to pull a report showing all agents in a single office with
> their number of transactions next to their name, that is a HUGE query.
> It would have to search the 400k worth of records for each of the
> agents on just that one report.
> A suggestions I was given
> I was told by a fellow programmer a better way to do this is to have an
> additional table that houses stats info and have the SQL server run
> automated reports everyday at say midnight where it updates that table.
> This table could show stuff like
> ** number of transactions for each user
> ** avg sales price on all transactions for each user
> ** avg commission on transaction for each user
> let me know your thoughts
> thanks in advance
> Monkey Girl

You didn't specify how quickly your data is growing but less than 1
million rows is a small database by most standards and probably isn't
going to be much trouble under any decent SQL Server implementation.

Pre-aggregating the data may be worthwhile but SQL Server has tools to
do that for you: Reporting Services or Analysis Services. It would be a
waste to create your own summary tables and then write the code just to
update them once a day.

> It would have to search the 400k worth of records for each of the
> agents on just that one report.

Not if you know what an index is... :-)

Hope this helps.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/...US,SQL.90).aspx
--

Design Idea

Need some design ideas.
I have to create a table which will have 2 types of IDs
MainID SubID
1 1
1 2
2 1
2 2
3 100
3 101
Basically I want to auto generate SubID for different MainIDs. For 2
different MainIDs, SubIDs can be same. Once the starting number is
determined the increment is always by 1.
Any ideas how this can be achived?"XXX" <sa@.nomail.com> wrote in message
news:#BH3Wz5ZFHA.3120@.TK2MSFTNGP12.phx.gbl...
> Need some design ideas.
> I have to create a table which will have 2 types of IDs
>
> MainID SubID
> 1 1
> 1 2
> 2 1
> 2 2
> 3 100
> 3 101
>
> Basically I want to auto generate SubID for different MainIDs. For 2
> different MainIDs, SubIDs can be same. Once the starting number is
> determined the increment is always by 1.
> Any ideas how this can be achived?
>
A trigger would probable work in this situation.
Rick Sawtell
MCT, MCSD, MCDBA|||On Thu, 2 Jun 2005 13:59:32 -0400, XXX wrote:

>Need some design ideas.
>I have to create a table which will have 2 types of IDs
>
>MainID SubID
>1 1
>1 2
>2 1
>2 2
>3 100
> 3 101
>
>Basically I want to auto generate SubID for different MainIDs. For 2
>different MainIDs, SubIDs can be same. Once the starting number is
>determined the increment is always by 1.
>Any ideas how this can be achived?
>
INSERT INTO MyTable (MainID, SubID, OtherColumns)
SELECT @.MainID, -- Passed in as parameter
COALESCE((SELECT MAX(SubID)
FROM MyTable
WHERE MainID = @.MainID),
@.StartofSubID), -- Passed in as parameter
@.OtherColumns -- Passed in as parameters
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Thanks Hugo.
It works. I think you missed the '+1' in your query.
INSERT INTO MyTable (MainID, SubID, OtherColumns)
SELECT @.MainID, -- Passed in as parameter
COALESCE((SELECT MAX(SubID)
FROM MyTable
WHERE MainID = @.MainID) +1 ,
@.StartofSubID), -- Passed in as parameter
@.OtherColumns -- Passed in as parameters
"Hugo Kornelis" <hugo@.pe_NO_rFact.in_SPAM_fo> wrote in message
news:1suu91djb3l14fu50enarjf5u5dliagpan@.
4ax.com...
> On Thu, 2 Jun 2005 13:59:32 -0400, XXX wrote:
>
> INSERT INTO MyTable (MainID, SubID, OtherColumns)
> SELECT @.MainID, -- Passed in as parameter
> COALESCE((SELECT MAX(SubID)
> FROM MyTable
> WHERE MainID = @.MainID),
> @.StartofSubID), -- Passed in as parameter
> @.OtherColumns -- Passed in as parameters
> Best, Hugo
> --
> (Remove _NO_ and _SPAM_ to get my e-mail address)