Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Friday, March 30, 2012

more problems with unique sequences

I have another different schema with the same data, but this one its like this

Code Snippet

CREATE Table events (
id INT not null,
PxMiss Real Not Null,
PyMiss Real Not Null,
filenames Varchar(50));

ALTER TABLE events
ADD CONSTRAINT pk_particle PRIMARY KEY (id,filenames);

GO

CREATE Table Muon (
idap INT Not Null,
id INT Not Null,
eventid INT Not Null,
Px Real,
Py Real,
Pz Real,
Kf Real,
Ee Real);

GO

CREATE Table Electron(
idap INT Not Null,
id INT NOT NULL,
eventid INT Not Null,
Px Real,
Py Real,
Pz Real,
Kf Real,
Ee Real);

GO

CREATE Table Jet (
idap INT Not Null,
id INT NOT NULL,
eventid INT Not Null,
Px Real,
Py Real,
Pz Real,
Kf Real,
Ee Real);

GO

Create View lepton AS
select * from Muon
Union all
select * from Electron;
GO

Create View particle AS
select * from lepton
Union all
select * from Jet;
GO

I need that every particle had a different idap, but all the date is filled in muon, electron and jet. and then is joined in a view called particle.

The way that you are going about this is likely to cause some problems.

For example, while it is possible to create a VIEW that would provide a unique idap for for each Particle, since it is a view and will be re-constituted at every execution, there is no certainity that the idap will be the same at each execution. (In my opinion -that is a big issue. -but maybe not for your situation...)

It seems more stable if you were to create a Particle idap that was the combination of each constituent Identifier + idap. Something like this for example:

CREATE VIEW Particle
AS

SELECT
'M' + cast( idap AS varchar(12)),
id,
eventid,
Px,
Py
Pz
Kf,
Ee
FROM Muon

UNION ALL

SELECT
'E' + cast( idap AS varchar(12),
id,
eventid,
Px,
Py,
Pz,
Kf,
Ee
FROM Electron

UNION ALL

SELECT
'J' + cast( idap AS varchar(12),
id,
eventid,
Px,
Py,
Pz,
Kf,
Ee
FROM Jet
GO

With this example, each idap will be unique, and also give you a clue about the constitutent component.

Wednesday, March 28, 2012

more FREETEXT

Continuing problems with FREETEXT...
So... I went through the wizard to create FullText catalog, everything went
nice without problems (selected table and fields to search on)
The problem is that I still have Item Count 0 (properties of the catalog)
after rebuild and full population was done (I have about 1000 records in the
table)
Fields that were searched are "ntext" all containing some data
What to do? What could be problem?
problem was that administrators were not un SQL users list and apparently
MSSearch service was not able to connect to server because of that
"borko" <borko@.borko.co.co> wrote in message
news:d81fbi$mmt$1@.ss405.t-com.hr...
> Continuing problems with FREETEXT...
> So... I went through the wizard to create FullText catalog, everything
> went nice without problems (selected table and fields to search on)
> The problem is that I still have Item Count 0 (properties of the catalog)
> after rebuild and full population was done (I have about 1000 records in
> the table)
> Fields that were searched are "ntext" all containing some data
> What to do? What could be problem?
>
>
|||Borko,
For the benefit of others & to clarify for others who may also encounter
this problem with either FREETEXT or CONTAINS when using SQL Server 2000
Full-text Search (FTS), if you remove or alter the BUILTIN\Administrators
login, then the "Microsoft Search" (mssearch.exe) service will not be able
to connect to SQL Server. Thus the MSSearch service will not be able to
successfully execute a Full or Incremental Population (0 item count is a
symptom of this problem). There are several kb articles on this topic and a
pure TSQL workaround if the BUILTIN\Administrators login must not exist for
security reasons, you can use the following T-SQL code as a workaround:
exec sp_grantlogin N'NT Authority\System'
exec sp_defaultdb N'NT Authority\System', N'master'
exec sp_defaultlanguage N'NT Authority\System','us_english'
exec sp_addsrvrolemember N'NT Authority\System', sysadmin
Hope that helps!
John
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"borko" <borko@.borko.co.co> wrote in message
news:d8m5vo$63m$1@.ss405.t-com.hr...[vbcol=seagreen]
> problem was that administrators were not un SQL users list and apparently
> MSSearch service was not able to connect to server because of that
>
> "borko" <borko@.borko.co.co> wrote in message
> news:d81fbi$mmt$1@.ss405.t-com.hr...
catalog)
>

more FREETEXT

Continuing problems with FREETEXT...
So... I went through the wizard to create FullText catalog, everything went
nice without problems (selected table and fields to search on)
The problem is that I still have Item Count 0 (properties of the catalog)
after rebuild and full population was done (I have about 1000 records in the
table)
Fields that were searched are "ntext" all containing some data
What to do? What could be problem?problem was that administrators were not un SQL users list and apparently
MSSearch service was not able to connect to server because of that
"borko" <borko@.borko.co.co> wrote in message
news:d81fbi$mmt$1@.ss405.t-com.hr...
> Continuing problems with FREETEXT...
> So... I went through the wizard to create FullText catalog, everything
> went nice without problems (selected table and fields to search on)
> The problem is that I still have Item Count 0 (properties of the catalog)
> after rebuild and full population was done (I have about 1000 records in
> the table)
> Fields that were searched are "ntext" all containing some data
> What to do? What could be problem?
>
>|||Borko,
For the benefit of others & to clarify for others who may also encounter
this problem with either FREETEXT or CONTAINS when using SQL Server 2000
Full-text Search (FTS), if you remove or alter the BUILTIN\Administrators
login, then the "Microsoft Search" (mssearch.exe) service will not be able
to connect to SQL Server. Thus the MSSearch service will not be able to
successfully execute a Full or Incremental Population (0 item count is a
symptom of this problem). There are several kb articles on this topic and a
pure TSQL workaround if the BUILTIN\Administrators login must not exist for
security reasons, you can use the following T-SQL code as a workaround:
exec sp_grantlogin N'NT Authority\System'
exec sp_defaultdb N'NT Authority\System', N'master'
exec sp_defaultlanguage N'NT Authority\System','us_english'
exec sp_addsrvrolemember N'NT Authority\System', sysadmin
Hope that helps!
John
--
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"borko" <borko@.borko.co.co> wrote in message
news:d8m5vo$63m$1@.ss405.t-com.hr...
> problem was that administrators were not un SQL users list and apparently
> MSSearch service was not able to connect to server because of that
>
> "borko" <borko@.borko.co.co> wrote in message
> news:d81fbi$mmt$1@.ss405.t-com.hr...
> > Continuing problems with FREETEXT...
> >
> > So... I went through the wizard to create FullText catalog, everything
> > went nice without problems (selected table and fields to search on)
> >
> > The problem is that I still have Item Count 0 (properties of the
catalog)
> > after rebuild and full population was done (I have about 1000 records in
> > the table)
> >
> > Fields that were searched are "ntext" all containing some data
> >
> > What to do? What could be problem?
> >
> >
> >
>

more FREETEXT

Continuing problems with FREETEXT...
So... I went through the wizard to create FullText catalog, everything went
nice without problems (selected table and fields to search on)
The problem is that I still have Item Count 0 (properties of the catalog)
after rebuild and full population was done (I have about 1000 records in the
table)
Fields that were searched are "ntext" all containing some data
What to do? What could be problem?problem was that administrators were not un SQL users list and apparently
MSSearch service was not able to connect to server because of that
"borko" <borko@.borko.co.co> wrote in message
news:d81fbi$mmt$1@.ss405.t-com.hr...
> Continuing problems with FREETEXT...
> So... I went through the wizard to create FullText catalog, everything
> went nice without problems (selected table and fields to search on)
> The problem is that I still have Item Count 0 (properties of the catalog)
> after rebuild and full population was done (I have about 1000 records in
> the table)
> Fields that were searched are "ntext" all containing some data
> What to do? What could be problem?
>
>|||Borko,
For the benefit of others & to clarify for others who may also encounter
this problem with either FREETEXT or CONTAINS when using SQL Server 2000
Full-text Search (FTS), if you remove or alter the BUILTIN\Administrators
login, then the "Microsoft Search" (mssearch.exe) service will not be able
to connect to SQL Server. Thus the MSSearch service will not be able to
successfully execute a Full or Incremental Population (0 item count is a
symptom of this problem). There are several kb articles on this topic and a
pure TSQL workaround if the BUILTIN\Administrators login must not exist for
security reasons, you can use the following T-SQL code as a workaround:
exec sp_grantlogin N'NT Authority\System'
exec sp_defaultdb N'NT Authority\System', N'master'
exec sp_defaultlanguage N'NT Authority\System','us_english'
exec sp_addsrvrolemember N'NT Authority\System', sysadmin
Hope that helps!
John
--
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"borko" <borko@.borko.co.co> wrote in message
news:d8m5vo$63m$1@.ss405.t-com.hr...
> problem was that administrators were not un SQL users list and apparently
> MSSearch service was not able to connect to server because of that
>
> "borko" <borko@.borko.co.co> wrote in message
> news:d81fbi$mmt$1@.ss405.t-com.hr...
catalog)[vbcol=seagreen]
>

Monday, March 26, 2012

moount points

I know how to create mount point in windows 20003 cluster, I am not sure how
to set it up with SQL 2005 running on the cluster.
Does sql need to be dependant on any of the disks? I have tried looking for
a guide, but cannot find.
current setup active active cluster running. I need to add san space which
will hold the databases. The san will be carved up into drive letters. each
drive letter will hold 3 mount points.
ie.
node 1
J:-2 mount point
k:2 mount point
l:2 mount point
node 2-
r:-2 mount point
s:2 mount point
t:2 mount point
each node would be able to own the disk if the other node failed over.
any help is appreciate. I have tried books online etc.. cannot find a good
step by step.;
Vision,
there are three area's you want to get familiar with prior to setting up a
production cluster
1) how to setup mountpoints in a cluster
http://support.microsoft.com/kb/280297
2) Be aware of this one, I have seen this once or twice after installing
SP1, if you do not have the symptom you do not need the hotfix.
http://support.microsoft.com/kb/898790
3) SQL 2005 and mount points
http://www.microsoft.com/technet/prodtechnol/sql/2005/physdbstor.mspx
http://support.microsoft.com/kb/819546
Test everything thoroughly before you put this into any production.
HTH,
_Edwin.
"vision" <vision@.discussions.microsoft.com> wrote in message
news:F0C6D7D8-F9F2-46DF-A128-2D384DACD40C@.microsoft.com...
> I know how to create mount point in windows 20003 cluster, I am not sure
how
> to set it up with SQL 2005 running on the cluster.
> Does sql need to be dependant on any of the disks? I have tried looking
for
> a guide, but cannot find.
> current setup active active cluster running. I need to add san space
which
> will hold the databases. The san will be carved up into drive letters.
each
> drive letter will hold 3 mount points.
> ie.
> node 1
> J:-2 mount point
> k:2 mount point
> l:2 mount point
> node 2-
> r:-2 mount point
> s:2 mount point
> t:2 mount point
> each node would be able to own the disk if the other node failed over.
> any help is appreciate. I have tried books online etc.. cannot find a
good
> step by step.;

monthtodate and yeartodate

I am creating an application with a report in VB .NET. I have all the data showing up and now I need to create a summary at the bottom of the report to show current, Month To Date, and Year To Date information for formulas and database entries. I have it working to a point. My question is what is the format to write a formula for these two fields to keep the data current even if I am not working in the current month. If I am doing November data it seems to work, but if my date is in October I am not getting the data for October, I am still getting November data. I looked in the Crystal Help file and they suggest to change the date on the computer in the control panel. hmmm.... Not very professional if you ask me. Any help would be great.Look under Report menu in Crystal - you can change the date (last option is "Set Report Print Date/Time").
Change that date and MonthToDate etc will use it for their dependent calculations.
Check the object model under .NET and hopefully that property is exposed and is able to be modified by your .NET code.

dave|||Dave,

Thank you for the reply. I have tried that, but I am still having problems. I can get the current data to show up in the MTD formula but it is not adding it the the previous data for the month. I am sure it is a placement problem but I could be worng there. I am also not getting an accurate sum for a formula that is a division problem. I have ordered a new book to help, but any input you may have would be great. Thank you.

Julie|||Hi Julie,

Here's what I would do:
You know you can create more than one group based on the same report field? Well, you can.
So, say you already have a group to show details date by date, create a group above this based on the same field, but in the "Change Group" options, set the "for each section" option to select 'for each year'.
That will give you a section that will show summary data based on the whole year.

Add another group based on the date, and in the "Change Group" options, set the "for each section" option to select 'for each month'.

The groups may not be in the order you want, so use Report menu, and then Change Group Expert, to define the order:
Should be Group 1 : year
Group 2 : month
Group 3 : day

then create your summaries.

Now in the case of one of my reports, I want data from the current month, even though it's incomplete, so in my report formula for selection by line (Report menu, Edit Selection Formula, Record...)
I use something like this:
(({DATEFIELD} > DateAdd("m", -12, {?Pm-?ReportDate})
and
{DATEFIELD} <= {?Pm-?ReportDate}).
Just bear in mind that if date is 15/12/04, report then goes back to 16/12/03.

IF you want completed months then you need a formula field first, something like this (we'll call it EndDate):

' get first day of current month.
formula = DateValue(Year(CurrentDate), Month(CurrentDate), 1

Then in my record selection formula I'd do this:
(({DATEFIELD} >= DateAdd("m", -12, {@.EndDate})
and
{DATEFIELD} < {@.EndDate}). ' note less than, because must be less than first of current month.........

Hope this helps

dave

Friday, March 23, 2012

Monthly Average (Expected)

Hi, I want to create a calculation in the cube (thinking that it can be done on that way). Please help me, you'll save a life :P

Problem:

TICKET NR

CUSTOMER

CITY

MONTH

YEAR

PROBLEM COUNT

IM1234499

BEU

ISTANBUL

1

2006

1

IM1234500

CTB

IZMIR

1

2006

1

IM1234501

BEU

ISTANBUL

2

2006

1

IM1234502

CTB

IZMIR

2

2006

1

IM1234503

BEU

ANKARA

3

2006

1

IM1234504

ASE

ANKARA

3

2006

1

IM1234505

BEU

ISTANBUL

4

2006

1

IM1234506

CTB

IZMIR

4

2006

1

IM1234507

BEU

ANKARA

5

2006

1

IM1234508

ASE

ISTANBUL

5

2006

1

IM1234509

BEU

ISTANBUL

5

2006

1

IM1234510

CTB

IZMIR

6

2006

1

IM1234511

BEU

ANKARA

6

2006

1

IM1234512

ASE

ADANA

6

2006

1

IM1234513

BEU

ISTANBUL

6

2006

1

IM1234514

CTB

IZMIR

7

2006

1

IM1234515

BEU

ANKARA

7

2006

1

IM1234516

ASE

ANKARA

7

2006

1

IM1234517

BEU

ANKARA

8

2006

1

IM1234518

ASE

ANKARA

9

2006

1

IM1234519

BEU

ANKARA

9

2006

1

IM1234520

ASE

ANKARA

9

2006

1

IM1234521

BEU

ANKARA

9

2006

1

IM1234522

BEU

ANKARA

10

2006

1

IM1234523

BEU

ANKARA

11

2006

1

IM1234524

BEU

IZMIR

12

2006

1

IM1234525

ASE

ISTANBUL

1

2007

1

IM1234526

ASE

IZMIR

1

2007

1

IM1234527

BEU

ISTANBUL

2

2007

1

IM1234528

ASE

IZMIR

2

2007

1

The table above lists some ticket records in my db. I have two measure;

* Total Count of Ticket
* Average Count of Ticket

First one works fine as expected...

Total PROBLEM COUNT

YEAR

MONTH

2006

Total 2006

2007

Total 2007

Total

CUSTOMER

1

2

3

4

5

6

7

8

9

10

11

12

1

2

ASE

1

1

1

1

2

6

2

1

3

9

BEU

1

1

1

1

2

2

1

1

2

1

1

1

15

1

1

16

CTB

1

1

1

1

1

5

5

Total

2

2

2

2

3

4

3

1

4

1

1

1

26

2

2

4

30

Here is the pivot view yearly and monthly. The total results are produced by Total Count of Ticket.
My second measure's result is as I waited but not my expected one as you see below.

2006

TRANS_MONTH

TOTAL PROB

MONTH AVG OF YEAR

MY EXPECTED AVERAGE

ASE

5

6

1,2

0,5

BEU

12

15

1,25

1,25

CTB

5

5

1

0,4

2007

TRANS_MONTH

TOTAL PROB

MONTH AVG OF YEAR

MY EXPECTED AVERAGE

ASE

2

3

1,5

1,5

BEU

1

1

1

0,5

CTB

0

0

0

0

I think you've got my problem ;-) The average provided by my measure is
total ticket count / count of transaction month

but I want to calculate the average with some other measurement;

If the year ended (past year)
Monthly Average is calculated by total ticket count / 12

If the year not ended (current year)
Monthly Average is calculated by total ticket count / number of last month

Let me show over the tables...

ASE has 6 tickets for 5 months in 2006 and
my expected monthly average of 2006 for ASE is 6/12=0,5 (divided by 12 = end of 2006)

BEU has 1 tickets for 1 months in 2007 (my last recorded month on db is Feb 2007 also) and
my expected monthly average of 2007 for BEU is 1/2=0,5 (divided by 2 = Feb)

Well, I think there is a super-dev would explain how to do it with a calculation (calculated member, right?)
Not good at MDX but waiting for your solution.

Thanks.

I've built a very small solution based on your data.

It consists of 1 fact table and 4 degenerate dimensions (Ticket,Customer,City,Month).

I've created 2 calculated member: the first one count months in the year, the second calculate the average based on the first one

It works fine (the average returns the data you expect) but it could be not exactly what you want (your real business scenario should be more complex!).

If you contact me via e-mail I can send you the SQL db (actually only 1 table!!!) and the AS solution.

francesco.dechirico@.fastwebnet.it(donotspam!)

|||thanks it works fine
sql