Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Sunday, March 25, 2012

Create table as I need it, how to reference in query?

I'll try to use the customer/orders example for my situation.
Let's say I have 10 customers and each customer has n order records. Most
of the time I will just accept the default order of the order records. In
other words, when I SELECT a customers orders I get them back in the order
they are in the table.
In some cases (remember, I'm not really dealing with customers/orders) I
want to explicitly re-order a customer's order records. Not by any
particular field. There is no logical pattern.
I was thinking that I could maintain a Customer_Orders_Order table. It
would look something like this:
[ CustomerID (FK to the customer tbl) ] [ OrderIndex ] [ OrderID (FK to
Order tbl) ]
the values might look like:
1 1 2
1 2 5
1 3 8
1 4 9
2 1 2
2 2 4
2 3 3
2 4 1
2 5 5
I would use this table to display the orders in the desired order in the UI.
OrderIndex would be the index in a ListView or DataGrid, etc.
My question is, would you store all the information in a single table or
would you create a table per customer to store this information and only if
the Customer's orders have actually been reordered from their default
presentation order (row order in the table)?
If your answer is create a table for each customer, how do you work with a
dynamically created table in a sproc or query? If my client app detects
that a user dragged an order above another order thus changing the
presentation order, I would create a table with a unique name, maybe
Tbl<customerName>_OrderPresentationOrdering. Then I could insert the
ordering information. Now, later when I want to display this customer's
orders and want to check if there is explicit presentation ordering that I
should use, how do I query the table I just created? Assuming I know the
naming convention used, can you concatenate a string in a sproc to build a
table name to be used in a Query?
Man, I hope this makes sense to someone, it's hard to explain.. :)
Thanks for any help,
SteveI was just thinking about this and realized that updates and inserts would
be involved due to the quantity of item in the update/insert. This got me
thinking... If I store this data per customer, inside the customer record,
then I don't need to have anything other than an array of OrderIDs.
So I can just have a delimited string stored in a field called
"OrderOrdering" (stupid name, my actual name would be "ProtocolOrdering" but
sticking with the example....)
something like:
4;2;7;1;3;5
Insert and updates are easy (fast) and there really is no need to normalize
data like this, is there? I won't use it for searches or anything.
If anyone has a compelling reason why I shouldn't do this, please share,
please, please.
"Steve" <sss@.sss.com> wrote in message
news:uThe317QGHA.6084@.TK2MSFTNGP10.phx.gbl...
> I'll try to use the customer/orders example for my situation.
> Let's say I have 10 customers and each customer has n order records. Most
> of the time I will just accept the default order of the order records. In
> other words, when I SELECT a customers orders I get them back in the order
> they are in the table.
> In some cases (remember, I'm not really dealing with customers/orders) I
> want to explicitly re-order a customer's order records. Not by any
> particular field. There is no logical pattern.
> I was thinking that I could maintain a Customer_Orders_Order table. It
> would look something like this:
> [ CustomerID (FK to the customer tbl) ] [ OrderIndex ] [ OrderID (FK
> to Order tbl) ]
>
> the values might look like:
> 1 1 2
> 1 2 5
> 1 3 8
> 1 4 9
> 2 1 2
> 2 2 4
> 2 3 3
> 2 4 1
> 2 5 5
> I would use this table to display the orders in the desired order in the
> UI. OrderIndex would be the index in a ListView or DataGrid, etc.
> My question is, would you store all the information in a single table or
> would you create a table per customer to store this information and only
> if the Customer's orders have actually been reordered from their default
> presentation order (row order in the table)?
> If your answer is create a table for each customer, how do you work with a
> dynamically created table in a sproc or query? If my client app detects
> that a user dragged an order above another order thus changing the
> presentation order, I would create a table with a unique name, maybe
> Tbl<customerName>_OrderPresentationOrdering. Then I could insert the
> ordering information. Now, later when I want to display this customer's
> orders and want to check if there is explicit presentation ordering that I
> should use, how do I query the table I just created? Assuming I know the
> naming convention used, can you concatenate a string in a sproc to build a
> table name to be used in a Query?
> Man, I hope this makes sense to someone, it's hard to explain.. :)
> Thanks for any help,
> Steve
>|||I have a feeling you're about to feel the wrath of JC.
But to answer your question, you would create a single table for this.
I see what you mean by your sorting information. In that case, I
consider that type of data to not have anything to do with the database
-- while it's human readable and client readable, I consider the data
to be arbitrary to anything accessing it within the database. It might
as well be random binary data for all your database is concerned. Now,
the question is, does this data belong in your database? You're
breaking encapsulation by storing this in your database if it's not
specific to the data. I make two exceptions to putting
application-specific data within a database. The first is when the
database is used by one and only one application, and will be used by
one and only one application for the purpose of storing data and logic
specific to that application. The second is when the performance or
implementation advantages of storing such application-specific logic
and data are exceptionally significant.
-Alan|||Steve wrote:
> I was just thinking about this and realized that updates and inserts would
> be involved due to the quantity of item in the update/insert. This got me
> thinking... If I store this data per customer, inside the customer record
,
> then I don't need to have anything other than an array of OrderIDs.
> So I can just have a delimited string stored in a field called
> "OrderOrdering" (stupid name, my actual name would be "ProtocolOrdering" b
ut
> sticking with the example....)
> something like:
> 4;2;7;1;3;5
> Insert and updates are easy (fast) and there really is no need to normaliz
e
> data like this, is there? I won't use it for searches or anything.
> If anyone has a compelling reason why I shouldn't do this, please share,
> please, please.
>
What reason would you have for NOT normalizing in this case?
You seem to be making something very simple into something very
complex. No question in my mind: One table in Normal Form. The keys
would be I assume (customer, order_index) and (customer, order_id).
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/ms130214(en-US,SQL.90).aspx
--|||I've upset JC?
(who is JC? Like Jesus Christ JC or is there a NG regular named JC?)
Yes, the data does belong to the database. I'll tell you why; given my
example, it sounds like an app preference or user preference, but this
ordering is actually used to generate source code. If a user logs in at
location A and initiates a build without knowing the ordering of the
records, that would result in invalid firmware and an irritated customer.
This is a feature I should have added from the get go, but I overlooked it.
So moving forward and agreeing (I assume we agree?) that the data does
belong in the DB, is this a valid case for a delimited string?
If not, make your case. I want to learn the right way.
Thanks,
Steve
"Alan Samet" <alansamet@.gmail.com> wrote in message
news:1141943305.488882.121840@.u72g2000cwu.googlegroups.com...
>I have a feeling you're about to feel the wrath of JC.
> But to answer your question, you would create a single table for this.
> I see what you mean by your sorting information. In that case, I
> consider that type of data to not have anything to do with the database
> -- while it's human readable and client readable, I consider the data
> to be arbitrary to anything accessing it within the database. It might
> as well be random binary data for all your database is concerned. Now,
> the question is, does this data belong in your database? You're
> breaking encapsulation by storing this in your database if it's not
> specific to the data. I make two exceptions to putting
> application-specific data within a database. The first is when the
> database is used by one and only one application, and will be used by
> one and only one application for the purpose of storing data and logic
> specific to that application. The second is when the performance or
> implementation advantages of storing such application-specific logic
> and data are exceptionally significant.
> -Alan
>|||>> So I can just have a delimited string stored in a field [sic] called"OrderOrde
ring" (stupid name, my actual name would be "ProtocolOrdering" but sticking
with the example....) something like:4;2;7;1;3;5 <<
Once more, you missed the most basic concepts again! Look up "First
Normal Form" (1NF), and learn why a column is not a field, a row is not
a record and a table is not a file. You might want to read at least
one book on RDBMS before you code in SQL.|||>I've upset JC?
>(who is JC? Like Jesus Christ JC or is there a NG regular named JC?)
I think you've probably figured this out by now.
So, you've decided to keep this in your database. Be aware of the
possible future implications of this. If you store multiple values a
single row, those values will be utterly useless in your database and
you'll be forced to do your sorting on the client. Next, if you dump
your front-end and it's rewritten, you'll have this artifact in your
database that those inheriting your work won't know what to do with
(or, given enough time, you won't either). In this situation, where
you've decided to store application-specific data in your database, at
least make it friendly to whoever may be administering thing. Store
your application-specific data in an application-specific location --
either a "helper" database that is specific to your application, or in
tables that are clearly indicated as being specific to your application
(e.g. App_MyApplication_InvoiceSorting) so that it's known they can be
dropped without implications once your application is no longer used.
-Alan|||>> 've upset JC? (who is JC? Like Jesus Christ JC or is there a NG regular
named JC?) <<
This si why I go by "--CELKO--" in the Newsgroup; peopel keep getting
us all the time.
hout knowing the ordering of the records [sic], that would result in invalid firm
ware and an irritated customer. <<
So the ordering has logical meanng in the data model!
So moving forward and agreeing (I assume we agree?) that the data does
belong in the DB, is this a valid case for a delimited string? <<
NO, it is a valid reason for a sequencing column in First Normal Form.
Since you will not post any DDL or even helpful narrative with
meaningful names, here is a guess:
CREATE TABLE FirmwareTemplates
(customer_id INTEGER NOT NULL
REFERENCES Custromers (customer_id),
template_seq INTEGER NOT NULL,
template_txt VARCHAR (255) NOT NULL,
PRIMARY KEY (customer_id, template_seq ));|||LOL.. let the NG lashings begin!
My entire database is application specific to a single app. It's entire
reason for existence is my application. It would seem in that case that ALL
my data is application specific. Is that bad? I'm getting the distinct
feeling that is somehow a bad thing?
Either way, yes, I am doing the sorting on the client. This is intentional.
My application is a high level firmware editor for our sales people. We
sell a product that can be customized (a bit) per customer. However, ALL
device's firmware must share some data that is constant.
One of the things that can be customized is the ordering of menu items in a
UI menu. All devices have the same menu items, but some customers want them
in a different order. I have approached this by maintaing a base shared
collection of menu items that all customers use. When they want to reorder
the items I store "meta data" (I'm not even sure if I understand that term,
seems like "settings" to me, but whatever) in their record.
Point is, I don't return a separate set of ordered menu item records for
each customer, I get the menu items for all customers, then the ordering
data for each customer, then on the client each customer has a reference to
the shared items and I order them the way they want in the UI.
Hope that makes a bit of sense.
"Alan Samet" <alansamet@.gmail.com> wrote in message
news:1141944627.875280.107100@.i40g2000cwc.googlegroups.com...
> I think you've probably figured this out by now.
> So, you've decided to keep this in your database. Be aware of the
> possible future implications of this. If you store multiple values a
> single row, those values will be utterly useless in your database and
> you'll be forced to do your sorting on the client. Next, if you dump
> your front-end and it's rewritten, you'll have this artifact in your
> database that those inheriting your work won't know what to do with
> (or, given enough time, you won't either). In this situation, where
> you've decided to store application-specific data in your database, at
> least make it friendly to whoever may be administering thing. Store
> your application-specific data in an application-specific location --
> either a "helper" database that is specific to your application, or in
> tables that are clearly indicated as being specific to your application
> (e.g. App_MyApplication_InvoiceSorting) so that it's known they can be
> dropped without implications once your application is no longer used.
> -Alan
>|||"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1141944759.875765.197440@.e56g2000cwe.googlegroups.com...
> This si why I go by "--CELKO--" in the Newsgroup; peopel keep getting
> us all the time.

>
> So the ordering has logical meanng in the data model!
yes, yes it does.

>
> So moving forward and agreeing (I assume we agree?) that the data does
> belong in the DB, is this a valid case for a delimited string? <<
> NO, it is a valid reason for a sequencing column in First Normal Form.
> Since you will not post any DDL or even helpful narrative with
> meaningful names, here is a guess:

> CREATE TABLE FirmwareTemplates
> (customer_id INTEGER NOT NULL
> REFERENCES Custromers (customer_id),
> template_seq INTEGER NOT NULL,
> template_txt VARCHAR (255) NOT NULL,
> PRIMARY KEY (customer_id, template_seq ));
>
Gotcha, I will investigate this, thanks for the suggestion!

Create table

Hi,
How would I create a table programmatically in a database. I am using C#
2005 Express edition.
For example I want to create a table named tblHours in a database
dbEmployees with the columns hours worked (integer), hourly pay (currency),
etc...
TIA
Roy
How about looking up "create table" in BOL?
ms-help://MS.SQLCC.v9/MS.SQLMobile.v3.en/SSMProg3/html/143cad25-5c1d-4c96-bd8b-6a95dbfb1b00.htm
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"Roy Gourgi" <royng@.videotron.ca> wrote in message
news:5rEuf.56416$DQ4.1492398@.weber.videotron.net.. .
> Hi,
> How would I create a table programmatically in a database. I am using C#
> 2005 Express edition.
> For example I want to create a table named tblHours in a database
> dbEmployees with the columns hours worked (integer), hourly pay
> (currency),
> etc...
>
> TIA
> Roy
>
>

Create table

Hi,
How would I create a table programmatically in a database. I am using C#
2005 Express edition.
For example I want to create a table named tblHours in a database
dbEmployees with the columns hours worked (integer), hourly pay (currency),
etc...
TIA
Roy>> create a table programmatically in a database.. <<
You do not do that at all. First, you write a data model of your real
world, then you implement in a schema. Your real world does not change
on the fly. If the model needs to add, alter or remove tables , you do
it with other tools, such as QA. Never in a front end program.
You might also want stop putting silly prefixes in front of data
element names (see ISO-11179).|||What do you mean "programatically?" If you mean permanently then you need
to get the Management Studio Express from
(http://msdn.microsoft.com/sql/express/)
If you mean you want to formulate a table based on some input (hopefully for
temporary usage) you just simply formulate a CREATE TABLE statement and
execute it in ADO.NET. Do you know how to execute a SQL Statement?
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Roy Gourgi" <royng@.videotron.ca> wrote in message
news:snEuf.56318$DQ4.1489316@.weber.videotron.net...
> Hi,
> How would I create a table programmatically in a database. I am using C#
> 2005 Express edition.
> For example I want to create a table named tblHours in a database
> dbEmployees with the columns hours worked (integer), hourly pay
> (currency), etc...
>
> TIA
> Roy
>|||What's wrong with prefixes? If you have dozens or hundreds of tables and
views, it is useful to distinguish them at a glance in stored procedure for
example.
Peter|||Nothing, the guy doesn't understand the term KISS (Keep It Simple Sweet).
Table prefixes are useful for segmenting code, personally, i don't use tbl_
type prefixes, but i do use vw_ because if and when I use views in code I
can quickly see that I am using a view in a query and then can more quickly
understand that there is further logic underneath that might be causing a
performance problem.
I prefix stored procedures using logical segmentation, for instance
events_sel; research_sel etc... groups objects together in the database to
make life (and development/maintanence) easier.
Tony.
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
news:%23ZSEWRSEGHA.916@.TK2MSFTNGP10.phx.gbl...
> What's wrong with prefixes? If you have dozens or hundreds of tables and
> views, it is useful to distinguish them at a glance in stored procedure
> for example.
> Peter
>|||"Tony Rogerson" <tonyrogerson@.sqlserverfaq.com>:
news:eGy3wlTEGHA.3200@.tk2msftngp13.phx.gbl...
> Nothing, the guy doesn't understand the term KISS (Keep It Simple Sweet).
> Table prefixes are useful for segmenting code, personally, i don't use
> tbl_ type prefixes, but i do use vw_ because if and when I use views in
> code I can quickly see that I am using a view in a query and then can more
> quickly understand that there is further logic underneath that might be
> causing a performance problem.
> I prefix stored procedures using logical segmentation, for instance
> events_sel; research_sel etc... groups objects together in the database to
> make life (and development/maintanence) easier.
> Tony.
> --
> Tony Rogerson
> SQL Server MVP
> http://sqlserverfaq.com - free video tutorials
>
> "Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
> news:%23ZSEWRSEGHA.916@.TK2MSFTNGP10.phx.gbl...
>
This is something newer
For me KISS stands for "keep it simple, stupid"
--
Andrey Odegov
avodeGOV@.yandex.ru
(remove GOV to respond)|||Celko has strong opinions and rarely is gentle with his advice (look past
that for some good advice much of the time, but as with all advice, there
are plenty of opinions.)
Personally, I don't like any type based prefixes on anything :) I do
something like this with stored procedures, functions etc (seperated by a $
(dollar sign) like table$action or purchaseOrder$delete, or something along
these lines.
On programming objects, I don't think either way is a big deal. I don't
prefix stuff with an indication if it is a procedure or a view, etc., but
either way is fine. I do feel that prefixes on tables, views and columns
look bad because the user is often presented these names, and they don't
need to know which are tables and which are views, and a programmer can tell
based on context. And since I always look at lists of objects in the
context of what they are:
select table_schema, table_name, table_type
from information_schema.tables
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
news:%23ZSEWRSEGHA.916@.TK2MSFTNGP10.phx.gbl...
> What's wrong with prefixes? If you have dozens or hundreds of tables and
> views, it is useful to distinguish them at a glance in stored procedure
> for example.
> Peter
>

Create table

Hi,
How would I create a table programmatically in a database. I am using C#
2005 Express edition.
For example I want to create a table named tblHours in a database
dbEmployees with the columns hours worked (integer), hourly pay (currency),
etc...
TIA
RoyHow about looking up "create table" in BOL?
ms-help://MS.SQLCC.v9/MS.SQLMobile.v3.en/SSMProg3/html/143cad25-5c1d-4c96-bd8b-6a95dbfb1b00.htm
--
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"Roy Gourgi" <royng@.videotron.ca> wrote in message
news:5rEuf.56416$DQ4.1492398@.weber.videotron.net...
> Hi,
> How would I create a table programmatically in a database. I am using C#
> 2005 Express edition.
> For example I want to create a table named tblHours in a database
> dbEmployees with the columns hours worked (integer), hourly pay
> (currency),
> etc...
>
> TIA
> Roy
>
>

Create table

Hi,
How would I create a table programmatically in a database. I am using C#
2005 Express edition.
For example I want to create a table named tblHours in a database
dbEmployees with the columns hours worked (integer), hourly pay (currency),
etc...
TIA
RoyHow about looking up "create table" in BOL?
ms-help://MS.SQLCC.v9/MS.SQLMobile.v3.en/SSMProg3/html/143cad25-5c1d-4c96-bd
8b-6a95dbfb1b00.htm
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"Roy Gourgi" <royng@.videotron.ca> wrote in message
news:5rEuf.56416$DQ4.1492398@.weber.videotron.net...
> Hi,
> How would I create a table programmatically in a database. I am using C#
> 2005 Express edition.
> For example I want to create a table named tblHours in a database
> dbEmployees with the columns hours worked (integer), hourly pay
> (currency),
> etc...
>
> TIA
> Roy
>
>

Thursday, March 22, 2012

CREATE SUBCUBE Syntax and Example

Can anyone provide an example of the right syntax for the CREATE SUBCUBE statement? And possibly discuss its use a bit? For example, from a client tool (like Excel), would there be any way to execute a CREATE SUBCUBE statement such that all browsing done within Excel was bound by the scope of the subcube? While perspectives provide a great server-based mechanism for creating scoped sections of a cube, I need a way to do this on the fly, from a client tool like Excel.

Thanks,
Dave Fackler
Just to follow-up on this for everyone else, I determined what syntax to use for the CREATE SUBCUBE statement. If you use the Browse window in BI Dev Studio or SS Management Studio, you can now define filters that the OWC control then respects as you drag and drop dimensions onto the rows and columns of the pivot table.

So, if you fire up Profiler and start a trace on Analysis Services, then use the Browse window to create a query with filters applied, you'll see the CREATE SUBCUBE statement come across. Very informative as you'll also see a host of other commands being executed by the Browse window!

At any rate, the CREATE SUBCUBE statement simply needs to contain a list of the filters you want in place defined on the columns axis of a standard select statement. Thus, the following would create a subcube on the Adventure Works database for just 2003 and 2004 in the US and UK:

CREATE SUBCUBE [Adventure Works] AS

SELECT ({[Customer].[Country].[United States], [Customer].[Country].[United Kingdom]}, {[Date].[Calendar Year].[CY 2003], [Date].[Calendar Year].[CY 2004]}) ON COLUMNS FROM [Adventure Works]

Notice that the subcube has the same name as the original cube in this example. It doesn't have to, but it can. Any subsequent queries to [Adventure Works] in the current session would then use the subcube and be limited to its scope.

Once the need for the subcube is gone, you can manually drop it as follows:

DROP SUBCUBE [Adventure Works]

This is exactly what the Browse windows in BI Dev Studio and SS Management Studio do (along with some other interesting statements).

Kudos to Profiler for helping me discover this on my own!!

Dave Fackler
|||

Hi Dave,

Some times it possible to have same result in MDX either by using CREATE SUBCUBE or by using FILETR function. Which method is better?

Regadrs,
Rakesh

CREATE SUBCUBE Syntax and Example

Can anyone provide an example of the right syntax for the CREATE SUBCUBE statement? And possibly discuss its use a bit? For example, from a client tool (like Excel), would there be any way to execute a CREATE SUBCUBE statement such that all browsing done within Excel was bound by the scope of the subcube? While perspectives provide a great server-based mechanism for creating scoped sections of a cube, I need a way to do this on the fly, from a client tool like Excel.

Thanks,
Dave Fackler
Just to follow-up on this for everyone else, I determined what syntax to use for the CREATE SUBCUBE statement. If you use the Browse window in BI Dev Studio or SS Management Studio, you can now define filters that the OWC control then respects as you drag and drop dimensions onto the rows and columns of the pivot table.

So, if you fire up Profiler and start a trace on Analysis Services, then use the Browse window to create a query with filters applied, you'll see the CREATE SUBCUBE statement come across. Very informative as you'll also see a host of other commands being executed by the Browse window!

At any rate, the CREATE SUBCUBE statement simply needs to contain a list of the filters you want in place defined on the columns axis of a standard select statement. Thus, the following would create a subcube on the Adventure Works database for just 2003 and 2004 in the US and UK:

CREATE SUBCUBE [Adventure Works] AS

SELECT ({[Customer].[Country].[United States], [Customer].[Country].[United Kingdom]}, {[Date].[Calendar Year].[CY 2003], [Date].[Calendar Year].[CY 2004]}) ON COLUMNS FROM [Adventure Works]

Notice that the subcube has the same name as the original cube in this example. It doesn't have to, but it can. Any subsequent queries to [Adventure Works] in the current session would then use the subcube and be limited to its scope.

Once the need for the subcube is gone, you can manually drop it as follows:

DROP SUBCUBE [Adventure Works]

This is exactly what the Browse windows in BI Dev Studio and SS Management Studio do (along with some other interesting statements).

Kudos to Profiler for helping me discover this on my own!!

Dave Fackler
|||

Hi Dave,

Some times it possible to have same result in MDX either by using CREATE SUBCUBE or by using FILETR function. Which method is better?

Regadrs,
Rakesh

sql

Create subcube action from currently sliced cube?

Hi guys! I'm wondering if its possible to create an action that would create a subcube by right clicking on a measure cell? For example, the user narrows the cube to 1000 accounts in a particular market. Now they want a cube based on only these 1000 accounts... so they right click on the "1000" cell, pick actions (just like drill through) and there's a chioce to create a subcube. And advice?

Thanks!

You can create a statement action that could execute some MDX against your Cube, but depending on your client browser, the statement action may not be exposed to the end user. Another option would be to create a reporting action that would launch an SSRS report that executed some MDX against your cube. Even if you were able to create an action that would create a subcube, I don't see how your front end tbrowser would be able to use it. The only thing that I've encountered that may solve your problem is by using proclarity. I believe Proclarity gives you the option to browse the cube and then save selected dimension members as named sets.

Hope this helps.

Van Dieu

create stored procedure in IF-structure

Hi everyone,

I'm currently struggeling in creating some SQL script to create stored procedures. I found the following example on MSDN:

Code Snippet

USE pubs
IF EXISTS (SELECT name FROM sysobjects
WHERE name = 'au_info2' AND type = 'P')
DROP PROCEDURE au_info2
GO
USE pubs
GO
CREATE PROCEDURE au_info2
@.lastname varchar(30) = 'D%',
@.firstname varchar(18) = '%'
AS
SELECT au_lname, au_fname, title, pub_name
FROM authors a INNER JOIN titleauthor ta
ON a.au_id = ta.au_id INNER JOIN titles t
ON t.title_id = ta.title_id INNER JOIN publishers p
ON t.pub_id = p.pub_id
WHERE au_fname LIKE @.firstname
AND au_lname LIKE @.lastname
GO

The thing is, I want to change and use it like this:

Code Snippet

USE pubsIF NOT EXISTS (SELECT name FROM sysobjects

CREATE PROCEDURE ...

USE pubs

GO

ALTER PROCEDURE au_info2 ...

But that does not seem to work.. I get the following error:

Code Snippet

Incorrect syntax near the keyword 'PROCEDURE'

Any idea's? Any help is appreciated!

Kind regards,

Frederik

The CREATE statement needs to be the first statement in the batch so you can't have it in after an IF clause.

I guess you could get round this by doing the following:

IF NOT EXISTS.....

EXEC('CREATE PROCEDURE au_info2 AS.....')

HTH!

|||Very dirty, but it works! I need it to avoid some errors when

replicating and such.. Thx!

Create star schema in SQL Server 2005?

Consider me brand new to data warehousing. I'm looking for a simple,
real-world example taking a simple transactional table, and getting all
"data warehouse" on it.
I know there's a star schema to design, but wouldn't I just do that within a
regular (OLTP) database?
We're looking to get into data warehousing in baby steps. I'm just trying
to be able to put an extremely simple real-world example in front of my boss
to explain what we would do. I.e. not concepts, but 1) start with
tblEmployee in the OLTP database... step 2...
Any help at all would be greatly appreciated.
Thanks,
rscYou might want to read Ralph Kimball's first book; he walks step-by-step
through the process, in detail. See:
http://www.amazon.com/gp/product/04...5964650?ie=UTF8
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Ronald S. Cook" <rcook@.westinis.com> wrote in message
news:ual%23jsqrGHA.4252@.TK2MSFTNGP02.phx.gbl...
> Consider me brand new to data warehousing. I'm looking for a simple,
> real-world example taking a simple transactional table, and getting all
> "data warehouse" on it.
> I know there's a star schema to design, but wouldn't I just do that within
> a regular (OLTP) database?
> We're looking to get into data warehousing in baby steps. I'm just trying
> to be able to put an extremely simple real-world example in front of my
> boss to explain what we would do. I.e. not concepts, but 1) start with
> tblEmployee in the OLTP database... step 2...
> Any help at all would be greatly appreciated.
> Thanks,
> rsc
>|||if you are not confortable to transform your data from your OLTP to a DW
schema
and if your OLTP database has a simple schema
and if you don't have to cleanse your data and synchronize with other
sources
then you can try to use view to create a "star schema".
for example, create a view which join your order header and order items
tables (the header contain some important information like the customerid
while the item contain the productid, price etc...)
create views to flatten your tables to create your dimensions (merge the
country, address & customer table; convert null values to unknown or N/A
values to insure a good data integrity)
then create your cubes and dimensions against these views.
another approach is to starts from an empty model and use the AS2005
templates feature.
this will generate the dimensions and cubes you need
and then create the source database and the table required.
after this, you can populate these tables, or replace these table by views,
your job is to found the right column in your source database to fill the
right destination column.
you can also found some samples on the web or in books; I remember books
with sample DW models, but I don't have the name in mind.
if you want to demonstrate this to your boss, create a useable model, not
only a customer analysis but a (at least) customer & product & time
analysis.
good luck.
Jerome.
"Ronald S. Cook" <rcook@.westinis.com> wrote in message
news:ual%23jsqrGHA.4252@.TK2MSFTNGP02.phx.gbl...
> Consider me brand new to data warehousing. I'm looking for a simple,
> real-world example taking a simple transactional table, and getting all
> "data warehouse" on it.
> I know there's a star schema to design, but wouldn't I just do that within
> a regular (OLTP) database?
> We're looking to get into data warehousing in baby steps. I'm just trying
> to be able to put an extremely simple real-world example in front of my
> boss to explain what we would do. I.e. not concepts, but 1) start with
> tblEmployee in the OLTP database... step 2...
> Any help at all would be greatly appreciated.
> Thanks,
> rsc
>|||Hello Ronald,
A good example of Star schemas is the Adventure Works data warehouse
example that comes with SQL Server 2005. The example covers Finance,
Sales (Internet and Reseller), based on fictitious Bicycle Company.
It's a great example to play with.
As for ETL there a few examples included in the samples that come with
SQL Server, but if you are looking for an architecture overview check
out this web cast by Kimball Associates consultant Joy Mundy \Using
SQL Server 2005 Integration Services to Populate a Kimball Method Data
Warehouse (Level 200).
http://msevents.microsoft.com/cui/W...&CountryCode=US
Joy co-wrote The Microsoft Data Warehouse Toolkit, which I can
recommend as a great starting point. The book includes the example of
populating the Adventure Works data warehouse from the Adventure Works
OLTP sample database.
The Microsoft Data Warehouse Toolkit: With SQL Server 2005 and the
Microsoft Business Intelligence Tool Set.
http://www.amazon.com/gp/product/04...r.blogspot.com/

Monday, March 19, 2012

Create Report Parameters Dynamically

Hi there,
I was wandering if it is possible to create report parameters on the
fly.
for example. table returns one moment 3 values, other moment 6 values.
depending how many values i would like to create report parameters...
Could anyone help?
Greetz,
Hippo from [NL]
--
remove xxx from mailIf you want to have a parameter that is a combo box filled from a query
that is not problem. If you want to vary the number of parameters then that
is fixed. In layout tab, click on a part of the report (empty part), go to
the report menu, parameters.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"hippo" <nijlpaard.xxx@.gmail.com> wrote in message
news:00ma515285q2fmmgouguksq2t4l538mlhh@.4ax.com...
> Hi there,
> I was wandering if it is possible to create report parameters on the
> fly.
> for example. table returns one moment 3 values, other moment 6 values.
> depending how many values i would like to create report parameters...
> Could anyone help?
>
> Greetz,
> Hippo from [NL]
> --
> remove xxx from mail|||Hello, i got the same problem, only the following:
Depending on returned values i would like to create a combobox.
For example, my dataset or stored procedure returned [x] names, and each
name has 5 possible values. Depending on [x] i would like to create
dynamically parameters. Is this possible?
"Bruce L-C [MVP]" wrote:
> If you want to have a parameter that is a combo box filled from a query
> that is not problem. If you want to vary the number of parameters then that
> is fixed. In layout tab, click on a part of the report (empty part), go to
> the report menu, parameters.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "hippo" <nijlpaard.xxx@.gmail.com> wrote in message
> news:00ma515285q2fmmgouguksq2t4l538mlhh@.4ax.com...
> > Hi there,
> >
> > I was wandering if it is possible to create report parameters on the
> > fly.
> >
> > for example. table returns one moment 3 values, other moment 6 values.
> > depending how many values i would like to create report parameters...
> >
> > Could anyone help?
> >
> >
> > Greetz,
> > Hippo from [NL]
> > --
> > remove xxx from mail
>
>|||Search Books On-Line on the phrase cascading parameters
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"RamR0m" <RamR0m@.discussions.microsoft.com> wrote in message
news:D54159D9-4F2D-4BE9-8873-862332EABBCD@.microsoft.com...
> Hello, i got the same problem, only the following:
> Depending on returned values i would like to create a combobox.
> For example, my dataset or stored procedure returned [x] names, and each
> name has 5 possible values. Depending on [x] i would like to create
> dynamically parameters. Is this possible?
> "Bruce L-C [MVP]" wrote:
> > If you want to have a parameter that is a combo box filled from a query
> > that is not problem. If you want to vary the number of parameters then
that
> > is fixed. In layout tab, click on a part of the report (empty part), go
to
> > the report menu, parameters.
> >
> >
> > --
> > Bruce Loehle-Conger
> > MVP SQL Server Reporting Services
> >
> > "hippo" <nijlpaard.xxx@.gmail.com> wrote in message
> > news:00ma515285q2fmmgouguksq2t4l538mlhh@.4ax.com...
> > > Hi there,
> > >
> > > I was wandering if it is possible to create report parameters on the
> > > fly.
> > >
> > > for example. table returns one moment 3 values, other moment 6 values.
> > > depending how many values i would like to create report parameters...
> > >
> > > Could anyone help?
> > >
> > >
> > > Greetz,
> > > Hippo from [NL]
> > > --
> > > remove xxx from mail
> >
> >
> >|||Thank you Bruce for you reply, but this isn't what i wish.
What i understand of Cascading Parameters is that you have to predefine your
parameters before execution.
What i would like is to have is, depending on values returned by the
dataset, vary the amount of visual parameters.
Greetz, RamR0m
> > > --
> > > Bruce Loehle-Conger
> > > MVP SQL Server Reporting Services
"Bruce L-C [MVP]" wrote:
> Search Books On-Line on the phrase cascading parameters
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "RamR0m" <RamR0m@.discussions.microsoft.com> wrote in message
> news:D54159D9-4F2D-4BE9-8873-862332EABBCD@.microsoft.com...
> > Hello, i got the same problem, only the following:
> >
> > Depending on returned values i would like to create a combobox.
> > For example, my dataset or stored procedure returned [x] names, and each
> > name has 5 possible values. Depending on [x] i would like to create
> > dynamically parameters. Is this possible?
> >
> > "Bruce L-C [MVP]" wrote:
> >
> > > If you want to have a parameter that is a combo box filled from a query
> > > that is not problem. If you want to vary the number of parameters then
> that
> > > is fixed. In layout tab, click on a part of the report (empty part), go
> to
> > > the report menu, parameters.
> > >
> > >
> > > --
> > > Bruce Loehle-Conger
> > > MVP SQL Server Reporting Services
> > >
> > > "hippo" <nijlpaard.xxx@.gmail.com> wrote in message
> > > news:00ma515285q2fmmgouguksq2t4l538mlhh@.4ax.com...
> > > > Hi there,
> > > >
> > > > I was wandering if it is possible to create report parameters on the
> > > > fly.
> > > >
> > > > for example. table returns one moment 3 values, other moment 6 values.
> > > > depending how many values i would like to create report parameters...
> > > >
> > > > Could anyone help?
> > > >
> > > >
> > > > Greetz,
> > > > Hippo from [NL]
> > > > --
> > > > remove xxx from mail
> > >
> > >
> > >
>
>|||>From everything I've seen, the parameters are hard coded into the RDL,
and there is no way to dynamically add or remove parameters at report
run time. You may want to see if someone from Microsoft knows if this
is a wishlist item for future versions.
If you are letting Reporting Services prompt the user for parameters,
the best thing I can think of that you can do is define the maximum
number of parameters, then use cascading parameters in a way that the
unnecessary parameters only have a single choice called "Not
Applicable" or "Skip Me". If you have an application that is calling
the report, you could prompt the user only for the parameters that you
really care about, and then behind the scenes fill in the remaining
parameters with dummy values that aren't actually needed to generate
your report data.
Ted

Thursday, March 8, 2012

Create objects calling other scripts.

Hello,
Can anybody tell me, how can i create one script that calls other scripts.
For example, i need to create object1, object2, object3 but for control
created releases i cant create my objects in the same script, so all that i
want its to create one 'run_all.sql' script that calls
'object1.sql','object2.sql', 'object3.sql'.
Can you give me any ideas, i've done this with isql or osql but i always
need to authenticate my self.
Thanks and best regards
A workaround would be to use a batch file to call osql for each script you
have.
Cristian Lefter, SQL Server MVP
"CC&JM" <CCJM@.discussions.microsoft.com> wrote in message
news:CC7ABEB1-AA65-468B-904A-88E42D5D2EDB@.microsoft.com...
> Hello,
> Can anybody tell me, how can i create one script that calls other scripts.
> For example, i need to create object1, object2, object3 but for control
> created releases i cant create my objects in the same script, so all that
> i
> want its to create one 'run_all.sql' script that calls
> 'object1.sql','object2.sql', 'object3.sql'.
> Can you give me any ideas, i've done this with isql or osql but i always
> need to authenticate my self.
> Thanks and best regards

Create objects calling other scripts.

Hello,
Can anybody tell me, how can i create one script that calls other scripts.
For example, i need to create object1, object2, object3 but for control
created releases i cant create my objects in the same script, so all that i
want its to create one 'run_all.sql' script that calls
'object1.sql','object2.sql', 'object3.sql'.
Can you give me any ideas, i've done this with isql or osql but i always
need to authenticate my self.
Thanks and best regardsA workaround would be to use a batch file to call osql for each script you
have.
Cristian Lefter, SQL Server MVP
"CC&JM" <CCJM@.discussions.microsoft.com> wrote in message
news:CC7ABEB1-AA65-468B-904A-88E42D5D2EDB@.microsoft.com...
> Hello,
> Can anybody tell me, how can i create one script that calls other scripts.
> For example, i need to create object1, object2, object3 but for control
> created releases i cant create my objects in the same script, so all that
> i
> want its to create one 'run_all.sql' script that calls
> 'object1.sql','object2.sql', 'object3.sql'.
> Can you give me any ideas, i've done this with isql or osql but i always
> need to authenticate my self.
> Thanks and best regards

Create objects calling other scripts.

Hello,
Can anybody tell me, how can i create one script that calls other scripts.
For example, i need to create object1, object2, object3 but for control
created releases i cant create my objects in the same script, so all that i
want its to create one 'run_all.sql' script that calls
'object1.sql','object2.sql', 'object3.sql'.
Can you give me any ideas, i've done this with isql or osql but i always
need to authenticate my self.
Thanks and best regardsA workaround would be to use a batch file to call osql for each script you
have.
Cristian Lefter, SQL Server MVP
"CC&JM" <CCJM@.discussions.microsoft.com> wrote in message
news:CC7ABEB1-AA65-468B-904A-88E42D5D2EDB@.microsoft.com...
> Hello,
> Can anybody tell me, how can i create one script that calls other scripts.
> For example, i need to create object1, object2, object3 but for control
> created releases i cant create my objects in the same script, so all that
> i
> want its to create one 'run_all.sql' script that calls
> 'object1.sql','object2.sql', 'object3.sql'.
> Can you give me any ideas, i've done this with isql or osql but i always
> need to authenticate my self.
> Thanks and best regards

Wednesday, March 7, 2012

create login

i need to make the following instructions (the name used are for example different than the database that im working)

Create new database 'Company'. Add new login (e.g. 'test_login') for 'Company' with password (e.g. '12345').
Create new user (e.g. 'test_user') for login 'test_login'. Set 'Database role' of user 'test_user' in 'Company' to 'db_owner'.
Create new schema (e.g. 'test_schema'). Set 'Default schema' of 'test_user' in 'Company' to 'test_schema'.
Input sql script 'Company.sql' as login 'test_login' to populate 'Company'.

im looking in the tutorial and for the moment i have this

CREATE LOGIN logs1 WITH PASSWORD = '12345'
CREATE USER luis FOR LOGIN logs1
WITH DEFAULT_SCHEMA;
GO

but i want to make all the steps.

Have a look in books on-line - it should be easy to find the instructions you need.

e.g. search for create database, roles,

|||i had previusly created the database with all the tables and data, then how can i create a schema for that and the functions that I found to set 'Database Role' are for Java, J#, C, etc, not for T-sql
|||

In books on-line filter the results by the database engine and you should get the t-sql help.

Look for create schema and create role.

You can also look for sp_addrole (the v2000 command) and it should link to the create role command.

You can also google "sql server create schema" but you need to know the command to do that

I'm not being awkward - you seem to be able to cope just have a problem with books on-line and you will get a lot more out of that rather than being told the code to write.

Create list of table names and size for a database

Hi there,

I am trying to create a list of all the tables in one database and then list the size of each table. So for example I want to create a table with the table name and table size for one DB

E.g

Table1 1111KB
Table2 123300MB
Table3 120448KB

etc for all the tables in a particukar DB

I know there is a stored procedure to list the sizes: 'sp_spaceused' but not sure how to script all this together.

can anyone help please!!

From

NewToSQLIf you don't do an UPDATE STATISTICS (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ua-uz_1mpf.asp) you'll probably be dealing with GIGO, but you could use:SELECT
Coalesce(8 * Sum(CASE WHEN si.indid IN (255) THEN si.reserved END), 0) AS blob_kb
, 8 * Sum(CASE WHEN si.indid IN (0, 1) THEN si.reserved END) AS data_kb
, Coalesce(8 * Sum(CASE WHEN si.indid NOT IN (0, 1, 255) THEN si.reserved END), 0) AS index_kb
, so.name
FROM dbo.sysobjects AS so
JOIN dbo.sysindexes AS si
ON (si.id = so.id)
WHERE 'U' = so.type
GROUP BY so.name
ORDER BY so.name-PatP|||Or...

USE Northwind
GO

SET NOCOUNT ON
GO

CREATE TABLE #SpaceUsed (
[name] varchar(255)
, [rows] varchar(25)
, [reserved] varchar(25)
, [data] varchar(25)
, [index_size] varchar(25)
, [unused] varchar(25)
)
GO

DECLARE @.tablename nvarchar(128)
, @.maxtablename nvarchar(128)
, @.cmd nvarchar(1000)
SELECT @.tablename = ''
, @.maxtablename = MAX(name)
FROM sysobjects
WHERE xtype='u'

WHILE @.tablename < @.maxtablename
BEGIN
SELECT @.tablename = MIN(name)
FROM sysobjects
WHERE xtype='u' and name > @.tablename

SET @.cmd='exec sp_spaceused['+@.tablename+']'
INSERT INTO #SpaceUsed EXEC sp_executesql @.cmd
END

SET NOCOUNT OFF
GO

SELECT * FROM #SpaceUsed
GO

DROP TABLE #SpaceUSed
GO|||I generally use

dbcc updateusage(0)
go

select sum(reserved)*8 as "Size in KB", object_name(id)
from sysindexes
where indid in (0, 1, 255)
group by id
order by 1 desc

The usage statistics tend to decay over time, as Pat pointed out.|||Is that just the index or the index and the datapage?|||Both, and text. The indid is what determines it.
indid = 0 = heap
indid = 1 = clustered index
indid = 255 = text/image

What I need is a way to subtract the nonclustered indexes, in the case that they happen to be on separate filegroups. Then I can get a script together to monitor space usage on a multi-filegroup system.|||If you look at my original posting, the non-clustered indicies are what are reported as index_kb. The data pages are either the heap or the clustered index, and the blob (TEXT and IMAGE) pages are just that, the index_kb are what are left.

-PatP|||I can't be too certain, but I think that M$ drops all of the index pages into the reserved count for indids 0 and 1. For a test, I created a table, loaded a bit of data into it, ran dbcc updateusage(0), and ran both our scripts. Then create an index on the table, run the dbcc again, run both scripts, and see what changes. In the second instance, it looks like the data page count goes up for the table.
This sort of thing just makes me a little more jealous of the Oracle DBA, who can get all of his size statistics with a lot less back-bending.|||Was the index you created clustered, or non-clustered? If it was clustered, then that is exactly the behavior that I would expect. If not, then hmmmm...

-PatP|||Thanks for your help, this worked a treat!!!!|||I'm just curioius, but which suggestion did you end up using?

-PatP|||I used Brett's in the end as it was similar to what I had originally tried to do. because I then put the contents of the table to an excel spreadsheet|||Pat: I added a nonclustered index. The definitions of the columns reserved, used, and dpages in books online are almost infuriating. I don't think there is any way to derrive the number of reserved pages for a particular index on a separate filegroup from the data. I thought about just rounding the dpages value up to the next multiple of 8, but that does not take into account highly fragmented indexes. It may be that you have to run dbcc showcontig to get the actual values, but that is too resource intensive for a simple monitor.

Sunday, February 19, 2012

Create Dynamic Table of Contents and Indexes

I was wondering if someone can tell me if there is a way to create a
dynamic table of contents and index for a report that is run.
For example, I need to create a directory of physicians based on a search
query of our database. So each report run would contain a different list of
doctors and locations, and on each query of the report the doctors would
show up on different pages of the report. I want to be able to create a
table of contents and an index for the report that will list the page
number the doctor first shows up on.
With MS Access VBA, I was able to do this by using the print event, in
which I would add each record to the access database table which contains
the table of contents, while the report was printing and therefore creating
the table of contents.
Is there a way (similiar) with SQL RS that I can accomplish this task?
--
Message posted via http://www.sqlmonster.comNot currently. The closest thing available right now is a Document Map.
This creates a bunch of bookmarks when you export to PDF, so that would
create an indexed report/PDF for you.
--
Cheers,
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"Tobby Lee via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:ff005f8e72c242a99456548fc63e62f0@.SQLMonster.com...
>I was wondering if someone can tell me if there is a way to create a
> dynamic table of contents and index for a report that is run.
> For example, I need to create a directory of physicians based on a search
> query of our database. So each report run would contain a different list
> of
> doctors and locations, and on each query of the report the doctors would
> show up on different pages of the report. I want to be able to create a
> table of contents and an index for the report that will list the page
> number the doctor first shows up on.
> With MS Access VBA, I was able to do this by using the print event, in
> which I would add each record to the access database table which contains
> the table of contents, while the report was printing and therefore
> creating
> the table of contents.
> Is there a way (similiar) with SQL RS that I can accomplish this task?
> --
> Message posted via http://www.sqlmonster.com|||Thanks for your response Jeff. Do you know if Crystal Reports or any other
reporting solution can handle the task of creating a Table of Contents and
document Index?
--
Message posted via http://www.sqlmonster.com|||Crystal Reports can do it, but it has to put it at the last page (it
generates the page numbers as it goes and accumulates them for display when
finished printing the records). Not an ideal solution for a TOC.
Brian Bischof
www.CrystalReportsBook.com
"Tobby Lee via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:7601e8aa56a14beba11468cd61e2ac41@.SQLMonster.com...
> Thanks for your response Jeff. Do you know if Crystal Reports or any other
> reporting solution can handle the task of creating a Table of Contents and
> document Index?
> --
> Message posted via http://www.sqlmonster.com|||This is a multipart message in MIME format
--Xananews.1.2.3
I was given a 'sleazy hack' to do this in RS, it requires the report to
be run twice once so it can work out the page numbers, second time it
can use them in the table of contents. If the table is going at the end
you may be able to change to a run once version! Good luck!
I never said it would be easy!
I've attached the file, and copied it below for those viewing via web.
-- --
Unfortunately, there's currently no good way to build a table of
contents.
And even adding defined execution order isn't going to help, since
pagination happens as a completely separate step from the rest of the
report. This is because you can request the same report with different
page
size/margin settings (and even an entirely different rendering target,
which
could radically change pagination). Under normal circumstances, we don't
want to force reexecution of the entire report just because you change
your
margins.
To handle table of contents type operations, we're going to (eventually)
have to implement an entirely new mode wherein we know that the body of
the
report contains references to page numbers, which will force the entire
report to reexecute if pagination information changes.
In the mean time, there's no general solution for the table of contents
problem.
But... Since you're doing this in a batch once a month, you may not
need a
fully general solution.
Without further ado, here's Sleazy Hack #792 ("Simulating Table of
Contents
in Batch Reporting Scenarios"):
1. Write a custom assembly containing a class that can write rows to a
TableOfContents table in your database.
Have shared methods for both initializing the TOC and writing a new
row
to the TOC.
Note: Don't forget to give it database permissions in the CAS file
when
you deploy it to your server.
See the documentation for details on custom assemblies.
2. In the Code section of the report, call the TOC initialization in
the
OnInit() event.
3. At the start of each section you want to appear in your TOC, put a
hidden textbox that contains the label you want to appear in your TOC.
4. In the page header, put a hidden textbox with something like the
following expression:
=Code.MyTOCClass.AddToTOC(Globals.PageNumber,ReportItems!Textbox1.Value
& ReportItems!Textbox2.Value & ReportItems!Textbox3.Value)
Texbox1, Textbox2 and Textbox3 are the names of the hidden textboxes
from step 3 (since only one will appear on any given page, the rest
will be
empty)
5. Add a dataset to your report which selects from the TableOfContents
table
6. Display the results of the TOC data set in a table at the end of
your
report*
7. Run the report twice. The first time will initialize the TOC. The
second time will use the values from the previous run.
* If you want it at the beginning, you'll either need to run the report
three times (the first to get some rows into the TOC table, the second
to
get the numbers populated correctly and the third to use those numbers)
or
you'll need to make sure the TOC table has the right number of rows to
begin
with (perhaps by not emptying it from the previous month) otherwise your
page numbers will be incorrect due to the TOC pushing things around.
This
isn't an issue if your TOC is only one page long and has PageBreakAtEnd,
however.
-- ---
Brian Bischof wrote:
> Crystal Reports can do it, but it has to put it at the last page (it
> generates the page numbers as it goes and accumulates them for
> display when finished printing the records). Not an ideal solution
> for a TOC.
>
> Brian Bischof
> www.CrystalReportsBook.com
>
> "Tobby Lee via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
> news:7601e8aa56a14beba11468cd61e2ac41@.SQLMonster.com...
> > Thanks for your response Jeff. Do you know if Crystal Reports or
> > any other reporting solution can handle the task of creating a
> > Table of Contents and document Index?
> >
> > --
> > Message posted via http://www.sqlmonster.com
--Xananews.1.2.3
Content-Type: Application/Octet-Stream; name=Sleazy Hack #792.txt
Content-Transfer-Encoding: base64
VW5mb3J0dW5hdGVseSwgdGhlcmUncyBjdXJyZW50bHkgbm8gZ29vZCB3YXkgdG8gYnVpbGQgYSB0
YWJsZSBvZiBjb250ZW50cy4NCg0KQW5kIGV2ZW4gYWRkaW5nIGRlZmluZWQgZXhlY3V0aW9uIG9y
ZGVyIGlzbid0IGdvaW5nIHRvIGhlbHAsIHNpbmNlDQpwYWdpbmF0aW9uIGhhcHBlbnMgYXMgYSBj
b21wbGV0ZWx5IHNlcGFyYXRlIHN0ZXAgZnJvbSB0aGUgcmVzdCBvZiB0aGUNCnJlcG9ydC4gIFRo
aXMgaXMgYmVjYXVzZSB5b3UgY2FuIHJlcXVlc3QgdGhlIHNhbWUgcmVwb3J0IHdpdGggZGlmZmVy
ZW50IHBhZ2UNCnNpemUvbWFyZ2luIHNldHRpbmdzIChhbmQgZXZlbiBhbiBlbnRpcmVseSBkaWZm
ZXJlbnQgcmVuZGVyaW5nIHRhcmdldCwgd2hpY2gNCmNvdWxkIHJhZGljYWxseSBjaGFuZ2UgcGFn
aW5hdGlvbikuIFVuZGVyIG5vcm1hbCBjaXJjdW1zdGFuY2VzLCB3ZSBkb24ndA0Kd2FudCB0byBm
b3JjZSByZWV4ZWN1dGlvbiBvZiB0aGUgZW50aXJlIHJlcG9ydCBqdXN0IGJlY2F1c2UgeW91IGNo
YW5nZSB5b3VyDQptYXJnaW5zLg0KVG8gaGFuZGxlIHRhYmxlIG9mIGNvbnRlbnRzIHR5cGUgb3Bl
cmF0aW9ucywgd2UncmUgZ29pbmcgdG8gKGV2ZW50dWFsbHkpDQpoYXZlIHRvIGltcGxlbWVudCBh
biBlbnRpcmVseSBuZXcgbW9kZSB3aGVyZWluIHdlIGtub3cgdGhhdCB0aGUgYm9keSBvZiB0aGUN
CnJlcG9ydCBjb250YWlucyByZWZlcmVuY2VzIHRvIHBhZ2UgbnVtYmVycywgd2hpY2ggd2lsbCBm
b3JjZSB0aGUgZW50aXJlDQpyZXBvcnQgdG8gcmVleGVjdXRlIGlmIHBhZ2luYXRpb24gaW5mb3Jt
YXRpb24gY2hhbmdlcy4NCg0KSW4gdGhlIG1lYW4gdGltZSwgdGhlcmUncyBubyBnZW5lcmFsIHNv
bHV0aW9uIGZvciB0aGUgdGFibGUgb2YgY29udGVudHMNCnByb2JsZW0uDQoNCkJ1dC4uLiBTaW5j
ZSB5b3UncmUgZG9pbmcgdGhpcyBpbiBhIGJhdGNoIG9uY2UgYSBtb250aCwgeW91IG1heSBub3Qg
bmVlZCBhDQpmdWxseSBnZW5lcmFsIHNvbHV0aW9uLg0KDQpXaXRob3V0IGZ1cnRoZXIgYWRvLCBo
ZXJlJ3MgU2xlYXp5IEhhY2sgIzc5MiAoIlNpbXVsYXRpbmcgVGFibGUgb2YgQ29udGVudHMNCmlu
IEJhdGNoIFJlcG9ydGluZyBTY2VuYXJpb3MiKToNCg0KMS4gIFdyaXRlIGEgY3VzdG9tIGFzc2Vt
Ymx5IGNvbnRhaW5pbmcgYSBjbGFzcyB0aGF0IGNhbiB3cml0ZSByb3dzIHRvIGENClRhYmxlT2ZD
b250ZW50cyB0YWJsZSBpbiB5b3VyIGRhdGFiYXNlLg0KICAgIEhhdmUgc2hhcmVkIG1ldGhvZHMg
Zm9yIGJvdGggaW5pdGlhbGl6aW5nIHRoZSBUT0MgYW5kIHdyaXRpbmcgYSBuZXcgcm93DQp0byB0
aGUgVE9DLg0KICAgIE5vdGU6ICBEb24ndCBmb3JnZXQgdG8gZ2l2ZSBpdCBkYXRhYmFzZSBwZXJt
aXNzaW9ucyBpbiB0aGUgQ0FTIGZpbGUgd2hlbg0KeW91IGRlcGxveSBpdCB0byB5b3VyIHNlcnZl
ci4NCiAgICBTZWUgdGhlIGRvY3VtZW50YXRpb24gZm9yIGRldGFpbHMgb24gY3VzdG9tIGFzc2Vt
YmxpZXMuDQoyLiAgSW4gdGhlIENvZGUgc2VjdGlvbiBvZiB0aGUgcmVwb3J0LCBjYWxsIHRoZSBU
T0MgaW5pdGlhbGl6YXRpb24gaW4gdGhlDQpPbkluaXQoKSBldmVudC4NCjMuICBBdCB0aGUgc3Rh
cnQgb2YgZWFjaCBzZWN0aW9uIHlvdSB3YW50IHRvIGFwcGVhciBpbiB5b3VyIFRPQywgcHV0IGEN
CmhpZGRlbiB0ZXh0Ym94IHRoYXQgY29udGFpbnMgdGhlIGxhYmVsIHlvdSB3YW50IHRvIGFwcGVh
ciBpbiB5b3VyIFRPQy4NCjQuICBJbiB0aGUgcGFnZSBoZWFkZXIsIHB1dCBhIGhpZGRlbiB0ZXh0
Ym94IHdpdGggc29tZXRoaW5nIGxpa2UgdGhlDQpmb2xsb3dpbmcgZXhwcmVzc2lvbjoNCiAgICA9
Q29kZS5NeVRPQ0NsYXNzLkFkZFRvVE9DKEdsb2JhbHMuUGFnZU51bWJlcixSZXBvcnRJdGVtcyFU
ZXh0Ym94MS5WYWx1ZQ0KJiBSZXBvcnRJdGVtcyFUZXh0Ym94Mi5WYWx1ZSAmIFJlcG9ydEl0ZW1z
IVRleHRib3gzLlZhbHVlKQ0KICAgIFRleGJveDEsIFRleHRib3gyIGFuZCBUZXh0Ym94MyBhcmUg
dGhlIG5hbWVzIG9mIHRoZSBoaWRkZW4gdGV4dGJveGVzDQpmcm9tIHN0ZXAgMyAoc2luY2Ugb25s
eSBvbmUgd2lsbCBhcHBlYXIgb24gYW55IGdpdmVuIHBhZ2UsIHRoZSByZXN0IHdpbGwgYmUNCmVt
cHR5KQ0KNS4gIEFkZCBhIGRhdGFzZXQgdG8geW91ciByZXBvcnQgd2hpY2ggc2VsZWN0cyBmcm9t
IHRoZSBUYWJsZU9mQ29udGVudHMNCnRhYmxlDQo2LiAgRGlzcGxheSB0aGUgcmVzdWx0cyBvZiB0
aGUgVE9DIGRhdGEgc2V0IGluIGEgdGFibGUgYXQgdGhlIGVuZCBvZiB5b3VyDQpyZXBvcnQqDQo3
LiAgUnVuIHRoZSByZXBvcnQgdHdpY2UuICBUaGUgZmlyc3QgdGltZSB3aWxsIGluaXRpYWxpemUg
dGhlIFRPQy4gIFRoZQ0Kc2Vjb25kIHRpbWUgd2lsbCB1c2UgdGhlIHZhbHVlcyBmcm9tIHRoZSBw
cmV2aW91cyBydW4uDQoNCiogSWYgeW91IHdhbnQgaXQgYXQgdGhlIGJlZ2lubmluZywgeW91J2xs
IGVpdGhlciBuZWVkIHRvIHJ1biB0aGUgcmVwb3J0DQp0aHJlZSB0aW1lcyAodGhlIGZpcnN0IHRv
IGdldCBzb21lIHJvd3MgaW50byB0aGUgVE9DIHRhYmxlLCB0aGUgc2Vjb25kIHRvDQpnZXQgdGhl
IG51bWJlcnMgcG9wdWxhdGVkIGNvcnJlY3RseSBhbmQgdGhlIHRoaXJkIHRvIHVzZSB0aG9zZSBu
dW1iZXJzKSBvcg0KeW91J2xsIG5lZWQgdG8gbWFrZSBzdXJlIHRoZSBUT0MgdGFibGUgaGFzIHRo
ZSByaWdodCBudW1iZXIgb2Ygcm93cyB0byBiZWdpbg0Kd2l0aCAocGVyaGFwcyBieSBub3QgZW1w
dHlpbmcgaXQgZnJvbSB0aGUgcHJldmlvdXMgbW9udGgpIG90aGVyd2lzZSB5b3VyDQpwYWdlIG51
bWJlcnMgd2lsbCBiZSBpbmNvcnJlY3QgZHVlIHRvIHRoZSBUT0MgcHVzaGluZyB0aGluZ3MgYXJv
dW5kLiAgVGhpcw0KaXNuJ3QgYW4gaXNzdWUgaWYgeW91ciBUT0MgaXMgb25seSBvbmUgcGFnZSBs
b25nIGFuZCBoYXMgUGFnZUJyZWFrQXRFbmQsDQpob3dldmVyLg0KDQo=--Xananews.1.2.3--|||You would think that with day and age, Microsoft would be smart enough to
figure out that people might want to create a table of contents.
Thanks Chris, I'll give it a try.
--
Message posted via http://www.sqlmonster.com|||Yeah, but I cut the MS guys some slack on RS features. They have created a
tremendous reporting platform from the ground up in just a couple of years.
I hear they were going to release it with SQL 2005, but bumped it up due to
early demand. Gotta like that. In any case, I'm having fun with it. All
in all, even with its limitations, it's better than any other reporting
solution I've used to date.
</rahrah>
--
Cheers,
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"Tobby Lee via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:b01f2ab3065d4d0bb7b57874d7543d59@.SQLMonster.com...
> You would think that with day and age, Microsoft would be smart enough to
> figure out that people might want to create a table of contents.
> Thanks Chris, I'll give it a try.
> --
> Message posted via http://www.sqlmonster.com|||I second that. I ditched the last CR report from our organisation two
weeks ago. I even had a pint or two to celebrate!
I always thought CR was overpriced for what it was, funnily enough now
I don't use it I seem to be getting free upgrades from them! Do you
think they are a little worried? ;)
Chris
Jeff A. Stucker wrote:
> Yeah, but I cut the MS guys some slack on RS features. They have
> created a tremendous reporting platform from the ground up in just a
> couple of years.
> I hear they were going to release it with SQL 2005, but bumped it up
> due to early demand. Gotta like that. In any case, I'm having fun
> with it. All in all, even with its limitations, it's better than any
> other reporting solution I've used to date.
> </rahrah>|||Chris...
Do you have some sample code or can you point me to something in the online
reference on how to add rows to a table from a custom class.
Dave
"Chris McGuigan" wrote:
> I was given a 'sleazy hack' to do this in RS, it requires the report to
> be run twice once so it can work out the page numbers, second time it
> can use them in the table of contents. If the table is going at the end
> you may be able to change to a run once version! Good luck!
> I never said it would be easy!
> I've attached the file, and copied it below for those viewing via web.
> -- --
> Unfortunately, there's currently no good way to build a table of
> contents.
> And even adding defined execution order isn't going to help, since
> pagination happens as a completely separate step from the rest of the
> report. This is because you can request the same report with different
> page
> size/margin settings (and even an entirely different rendering target,
> which
> could radically change pagination). Under normal circumstances, we don't
> want to force reexecution of the entire report just because you change
> your
> margins.
> To handle table of contents type operations, we're going to (eventually)
> have to implement an entirely new mode wherein we know that the body of
> the
> report contains references to page numbers, which will force the entire
> report to reexecute if pagination information changes.
> In the mean time, there's no general solution for the table of contents
> problem.
> But... Since you're doing this in a batch once a month, you may not
> need a
> fully general solution.
> Without further ado, here's Sleazy Hack #792 ("Simulating Table of
> Contents
> in Batch Reporting Scenarios"):
> 1. Write a custom assembly containing a class that can write rows to a
> TableOfContents table in your database.
> Have shared methods for both initializing the TOC and writing a new
> row
> to the TOC.
> Note: Don't forget to give it database permissions in the CAS file
> when
> you deploy it to your server.
> See the documentation for details on custom assemblies.
> 2. In the Code section of the report, call the TOC initialization in
> the
> OnInit() event.
> 3. At the start of each section you want to appear in your TOC, put a
> hidden textbox that contains the label you want to appear in your TOC.
> 4. In the page header, put a hidden textbox with something like the
> following expression:
> =Code.MyTOCClass.AddToTOC(Globals.PageNumber,ReportItems!Textbox1.Value
> & ReportItems!Textbox2.Value & ReportItems!Textbox3.Value)
> Texbox1, Textbox2 and Textbox3 are the names of the hidden textboxes
> from step 3 (since only one will appear on any given page, the rest
> will be
> empty)
> 5. Add a dataset to your report which selects from the TableOfContents
> table
> 6. Display the results of the TOC data set in a table at the end of
> your
> report*
> 7. Run the report twice. The first time will initialize the TOC. The
> second time will use the values from the previous run.
> * If you want it at the beginning, you'll either need to run the report
> three times (the first to get some rows into the TOC table, the second
> to
> get the numbers populated correctly and the third to use those numbers)
> or
> you'll need to make sure the TOC table has the right number of rows to
> begin
> with (perhaps by not emptying it from the previous month) otherwise your
> page numbers will be incorrect due to the TOC pushing things around.
> This
> isn't an issue if your TOC is only one page long and has PageBreakAtEnd,
> however.
> -- ---
>
> Brian Bischof wrote:
> > Crystal Reports can do it, but it has to put it at the last page (it
> > generates the page numbers as it goes and accumulates them for
> > display when finished printing the records). Not an ideal solution
> > for a TOC.
> >
> >
> > Brian Bischof
> > www.CrystalReportsBook.com
> >
> >
> >
> > "Tobby Lee via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
> > news:7601e8aa56a14beba11468cd61e2ac41@.SQLMonster.com...
> > > Thanks for your response Jeff. Do you know if Crystal Reports or
> > > any other reporting solution can handle the task of creating a
> > > Table of Contents and document Index?
> > >
> > > --
> > > Message posted via http://www.sqlmonster|||Never mind I misread your solution the first time.
Dave
"Dlloyd" wrote:
> Chris...
> Do you have some sample code or can you point me to something in the online
> reference on how to add rows to a table from a custom class.
> Dave
> "Chris McGuigan" wrote:
> > I was given a 'sleazy hack' to do this in RS, it requires the report to
> > be run twice once so it can work out the page numbers, second time it
> > can use them in the table of contents. If the table is going at the end
> > you may be able to change to a run once version! Good luck!
> > I never said it would be easy!
> >
> > I've attached the file, and copied it below for those viewing via web.
> >
> > -- --
> >
> > Unfortunately, there's currently no good way to build a table of
> > contents.
> >
> > And even adding defined execution order isn't going to help, since
> > pagination happens as a completely separate step from the rest of the
> > report. This is because you can request the same report with different
> > page
> > size/margin settings (and even an entirely different rendering target,
> > which
> > could radically change pagination). Under normal circumstances, we don't
> > want to force reexecution of the entire report just because you change
> > your
> > margins.
> > To handle table of contents type operations, we're going to (eventually)
> > have to implement an entirely new mode wherein we know that the body of
> > the
> > report contains references to page numbers, which will force the entire
> > report to reexecute if pagination information changes.
> >
> > In the mean time, there's no general solution for the table of contents
> > problem.
> >
> > But... Since you're doing this in a batch once a month, you may not
> > need a
> > fully general solution.
> >
> > Without further ado, here's Sleazy Hack #792 ("Simulating Table of
> > Contents
> > in Batch Reporting Scenarios"):
> >
> > 1. Write a custom assembly containing a class that can write rows to a
> > TableOfContents table in your database.
> > Have shared methods for both initializing the TOC and writing a new
> > row
> > to the TOC.
> > Note: Don't forget to give it database permissions in the CAS file
> > when
> > you deploy it to your server.
> > See the documentation for details on custom assemblies.
> > 2. In the Code section of the report, call the TOC initialization in
> > the
> > OnInit() event.
> > 3. At the start of each section you want to appear in your TOC, put a
> > hidden textbox that contains the label you want to appear in your TOC.
> > 4. In the page header, put a hidden textbox with something like the
> > following expression:
> >
> > =Code.MyTOCClass.AddToTOC(Globals.PageNumber,ReportItems!Textbox1.Value
> > & ReportItems!Textbox2.Value & ReportItems!Textbox3.Value)
> > Texbox1, Textbox2 and Textbox3 are the names of the hidden textboxes
> > from step 3 (since only one will appear on any given page, the rest
> > will be
> > empty)
> > 5. Add a dataset to your report which selects from the TableOfContents
> > table
> > 6. Display the results of the TOC data set in a table at the end of
> > your
> > report*
> > 7. Run the report twice. The first time will initialize the TOC. The
> > second time will use the values from the previous run.
> >
> > * If you want it at the beginning, you'll either need to run the report
> > three times (the first to get some rows into the TOC table, the second
> > to
> > get the numbers populated correctly and the third to use those numbers)
> > or
> > you'll need to make sure the TOC table has the right number of rows to
> > begin
> > with (perhaps by not emptying it from the previous month) otherwise your
> > page numbers will be incorrect due to the TOC pushing things around.
> > This
> > isn't an issue if your TOC is only one page long and has PageBreakAtEnd,
> > however.
> >
> > -- ---
> >
> >
> > Brian Bischof wrote:
> >
> > > Crystal Reports can do it, but it has to put it at the last page (it
> > > generates the page numbers as it goes and accumulates them for
> > > display when finished printing the records). Not an ideal solution
> > > for a TOC.
> > >
> > >
> > > Brian Bischof
> > > www.CrystalReportsBook.com
> > >
> > >
> > >
> > > "Tobby Lee via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
> > > news:7601e8aa56a14beba11468cd61e2ac41@.SQLMonster.com...
> > > > Thanks for your response Jeff. Do you know if Crystal Reports or
> > > > any other reporting solution can handle the task of creating a
> > > > Table of Contents and document Index?
> > > >
> > > > --
> > > > Message posted via http://www.sqlmonster|||Hi,
I haven't actually used this hack so I don't have an RDL file for you.
Try Tobby Lee, he said he was going to try it out.
If you are stuck creating the custom assembly, have a look at this site;
http://blogs.sqlxml.org/bryantlikes/articles/824.aspx?Pending=true
There are loads of ways to add rows to tables in VB (sorry I don't do
C).
I prefer sending raw SQL commands, but that's just the way I am!
If you're using old ADO (2.6 - 2.8) you will need a connection object
first then you can create a command object and issue a SQL 'insert'
statement. Below is an example BUT it is not 'best practice' nor
particularly efficient in the form I have given you. It should be
enough to get you going though, I'd suggest you get a book on the lines
of SQL for Developers or on ADO.Net (or earlier);
You will need to add a reference to an ADO namespace to your project
for this to work. ADO.Net is significantly different to previous
versions of ADO.
Heres the code;
Public Sub AddLine(Value1 As String, Value2 As String)
Dim oCon As ADODB.Connection
Set oCon = New ADODB.Connection
'Open a connection to the database
'
oCon.ConnectionString = "Provider=SQLOLEDB; Data Source=YourServer;
InitialCatalog=YourDB; User Id=yourid; Password=yourpassword"
oCon.Open
'Set up a command to do the INSERT
'
Set oCon.CommandText = "Insert Into YourTable (Fieldname1,
Fieldname2) Values ('" & Value1 & "','" & Value2 & "')"
'Actually INSERT the record
oCon.Execute
oCon.Close
Set oCon = Nothing
End Sub
Hope it helps ...
Chris
Dlloyd wrote:
> Chris...
> Do you have some sample code or can you point me to something in the
> online reference on how to add rows to a table from a custom class.
> Dave
> "Chris McGuigan" wrote:
> > I was given a 'sleazy hack' to do this in RS, it requires the
> > report to be run twice once so it can work out the page numbers,
> > second time it can use them in the table of contents. If the table
> > is going at the end you may be able to change to a run once
> > version! Good luck! I never said it would be easy!
> >
> > I've attached the file, and copied it below for those viewing via
> > web.
> >
> > -- --
> >
> > Unfortunately, there's currently no good way to build a table of
> > contents.
> >
> > And even adding defined execution order isn't going to help, since
> > pagination happens as a completely separate step from the rest of
> > the report. This is because you can request the same report with
> > different page
> > size/margin settings (and even an entirely different rendering
> > target, which
> > could radically change pagination). Under normal circumstances, we
> > don't want to force reexecution of the entire report just because
> > you change your
> > margins.
> > To handle table of contents type operations, we're going to
> > (eventually) have to implement an entirely new mode wherein we know
> > that the body of the
> > report contains references to page numbers, which will force the
> > entire report to reexecute if pagination information changes.
> >
> > In the mean time, there's no general solution for the table of
> > contents problem.
> >
> > But... Since you're doing this in a batch once a month, you may not
> > need a
> > fully general solution.
> >
> > Without further ado, here's Sleazy Hack #792 ("Simulating Table of
> > Contents
> > in Batch Reporting Scenarios"):
> >
> > 1. Write a custom assembly containing a class that can write rows
> > to a TableOfContents table in your database.
> > Have shared methods for both initializing the TOC and writing a
> > new row
> > to the TOC.
> > Note: Don't forget to give it database permissions in the CAS
> > file when
> > you deploy it to your server.
> > See the documentation for details on custom assemblies.
> > 2. In the Code section of the report, call the TOC initialization
> > in the
> > OnInit() event.
> > 3. At the start of each section you want to appear in your TOC,
> > put a hidden textbox that contains the label you want to appear in
> > your TOC. 4. In the page header, put a hidden textbox with
> > something like the following expression:
> >
> > =Code.MyTOCClass.AddToTOC(Globals.PageNumber,ReportItems!Textbox1.Va
> > lue & ReportItems!Textbox2.Value & ReportItems!Textbox3.Value)
> > Texbox1, Textbox2 and Textbox3 are the names of the hidden
> > textboxes from step 3 (since only one will appear on any given
> > page, the rest will be
> > empty)
> > 5. Add a dataset to your report which selects from the
> > TableOfContents table
> > 6. Display the results of the TOC data set in a table at the end of
> > your
> > report*
> > 7. Run the report twice. The first time will initialize the TOC.
> > The second time will use the values from the previous run.
> >
> > * If you want it at the beginning, you'll either need to run the
> > report three times (the first to get some rows into the TOC table,
> > the second to
> > get the numbers populated correctly and the third to use those
> > numbers) or
> > you'll need to make sure the TOC table has the right number of rows
> > to begin
> > with (perhaps by not emptying it from the previous month) otherwise
> > your page numbers will be incorrect due to the TOC pushing things
> > around. This
> > isn't an issue if your TOC is only one page long and has
> > PageBreakAtEnd, however.
> >
> > -- ---
> >
> >
> > Brian Bischof wrote:
> >
> > > Crystal Reports can do it, but it has to put it at the last page
> > > (it generates the page numbers as it goes and accumulates them for
> > > display when finished printing the records). Not an ideal solution
> > > for a TOC.
> > >
> > >
> > > Brian Bischof
> > > www.CrystalReportsBook.com
> > >
> > >
> > >
> > > "Tobby Lee via SQLMonster.com" <forum@.SQLMonster.com> wrote in
> > > message news:7601e8aa56a14beba11468cd61e2ac41@.SQLMonster.com...
> > > > Thanks for your response Jeff. Do you know if Crystal Reports or
> > > > any other reporting solution can handle the task of creating a
> > > > Table of Contents and document Index?
> > > >
> > > > --
> > > > Message posted via http://www.sqlmonster

Create Dynamic Table of Contents and Indexes

I was wondering if someone can tell me if there is a way to create a dynamic table of contents and index for a report that is run.

For example, I need to create a directory of physicians based on a search query of our database. So each report would contain a list of doctors and locations, but on each query of the report the doctors would show up on different pages of the report. I want to be able to create a table of contents and an index for the report that will list the page number the doctor first shows up on.

With MS Access VBA, I was able to do this by using the print event, in which I would add each record to the access database table which contains the table of contents, while the report was printing and therefore creating the table of contents.

Is there a way (similiar) with SQL RS that I can accomplish this task?

My reports have lots of pages, about 3-20 pages per report, so I too thought about including a table of contents.

Anyone found a solution yet?

Friday, February 17, 2012

Create Database with 2 filegroups and...

I create one table on each filegroup, for example:
Database mywind
file1 = mywind_data_1
filegroup1= new_customers
file2 = mywind_data_2
filegroup2 = sales
Then the t1 table is created on new_customers and the t2 table is created on
sales.
If I delete t1 I can restore only this table ? Using one backup from
filegroups?
I can restore only this table ?
ThanksIt depends on what you want to achieve. You can restore only that table to a new database and copy
the data into the original database. See the PATRTIAL option of the RESTORE command. This is an
advanced feature, make sure you read the information in Books Online, understand it and test.
You cannot restore only that table into the original database, not to an earlier point in time
(before the accidental delete). This is because you need to apply all transaction log backups up to
current point in time, so the delete will be applied.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Mônica" <Mnica@.discussions.microsoft.com> wrote in message
news:5CF5BEF7-0E67-4AC9-AFC3-2F37B9512A14@.microsoft.com...
>I create one table on each filegroup, for example:
> Database mywind
> file1 = mywind_data_1
> filegroup1= new_customers
> file2 = mywind_data_2
> filegroup2 = sales
> Then the t1 table is created on new_customers and the t2 table is created on
> sales.
> If I delete t1 I can restore only this table ? Using one backup from
> filegroups?
> I can restore only this table ?
> Thanks