Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Sunday, March 25, 2012

ASP, SQL, long text data problems...

I have an ASP page that will take form info that a user has entered,
then save it into SQL server, and retrive and display the info on
another page. My problem is with long text data (10,000 bytes or
more). It appears to save the long text data, as in it gives no
errors... but it does not save it. In the SQL table, the field is
defined as ntext... So why won't it save?

Thanks in advance,
adamAdam (ootena@.imsg.com) writes:
> I have an ASP page that will take form info that a user has entered,
> then save it into SQL server, and retrive and display the info on
> another page. My problem is with long text data (10,000 bytes or
> more). It appears to save the long text data, as in it gives no
> errors... but it does not save it. In the SQL table, the field is
> defined as ntext... So why won't it save?

I guess you need to post your code, so that people here can have a
reasonble chance to spot your error. You are using the AppendChunk on
the Field object?

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Adam (ootena@.imsg.com) writes:
> I guess I need an example of the GetChunk, AppendChunk... I havent
> been able to find one that makes sense to me.

In the MDAC Books Online there are examples of using AppendChunk. This
should also be on MSDN.

Did you try searching for AppendChunk on Google? I seem to get quite some
hits.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Cool, thanks for the books online... that helped a lot later man

Thursday, March 22, 2012

ASP Impersonation - null user

Hi, this could be an ASP, IIS or SQL server question so please bear with me!
We have an sql server 2000 machine and our IIS 6 machine running seperately
but on the same domain. I can connect fine to the database without using
impersonation, but when it's enabled I get the error:
"Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection."
I've tried looking into this, and noted suggestions of copying accounts to
the database server machine.. is this really necessary? they're on the same
domain, and that would be lots of hassle as I'm hoping to allow anyone on
the domain access to the pages, with authorisation being ran against the sql
server roles/security groups.
Hope my query makes sense.. for info when I check
System.Security.Principal.WindowsIdentity.GetCurrent().Name I get the
expected result.
cheers for any help,
ChrisNot Me
Was your SQL Server set up with Windows Authentication only?
"Not Me" <Not.Me@.nada.nope.hk.za> wrote in message
news:1166521469.754869@.ucsnew2.ncl.ac.uk...
> Hi, this could be an ASP, IIS or SQL server question so please bear with
> me!
> We have an sql server 2000 machine and our IIS 6 machine running
> seperately but on the same domain. I can connect fine to the database
> without using impersonation, but when it's enabled I get the error:
> "Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection."
> I've tried looking into this, and noted suggestions of copying accounts to
> the database server machine.. is this really necessary? they're on the
> same domain, and that would be lots of hassle as I'm hoping to allow
> anyone on the domain access to the pages, with authorisation being ran
> against the sql server roles/security groups.
> Hope my query makes sense.. for info when I check
> System.Security.Principal.WindowsIdentity.GetCurrent().Name I get the
> expected result.
> cheers for any help,
> Chris
>|||"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%237eitB2IHHA.1280@.TK2MSFTNGP04.phx.gbl...
> "Not Me" <Not.Me@.nada.nope.hk.za> wrote in message
> news:1166521469.754869@.ucsnew2.ncl.ac.uk...
[vbcol=seagreen]
> Was your SQL Server set up with Windows Authentication only?
Aha, I'll check with the admin... was just reading up on how mixed-mode is
required in some circumstances, is this what you're getting at?
cheers,
Chris|||Yes. you can changed it and re-connict again
"Not Me" <Not.Me@.nada.nope.hk.za> wrote in message
news:1166527936.903888@.ucsnew2.ncl.ac.uk...
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%237eitB2IHHA.1280@.TK2MSFTNGP04.phx.gbl...
>
> Aha, I'll check with the admin... was just reading up on how mixed-mode is
> required in some circumstances, is this what you're getting at?
> cheers,
> Chris
>
>|||Hmmm, it is already in mixed-mode.
Any other ideas?
cheers,
Chris
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:e1vPDJ2IHHA.4712@.TK2MSFTNGP04.phx.gbl...
> Yes. you can changed it and re-connict again
>
> "Not Me" <Not.Me@.nada.nope.hk.za> wrote in message
> news:1166527936.903888@.ucsnew2.ncl.ac.uk...
>|||http://support.microsoft.com/?kbid=555017
http://www.microsoft.com/technet/pr...ds/default.mspx
"Not Me" <Not.Me@.nada.nope.hk.za> wrote in message
news:1166532551.477926@.ucsnew2.ncl.ac.uk...
> Hmmm, it is already in mixed-mode.
> Any other ideas?
> cheers,
> Chris
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:e1vPDJ2IHHA.4712@.TK2MSFTNGP04.phx.gbl...
>|||"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eyAiGA3IHHA.3268@.TK2MSFTNGP04.phx.gbl...
> http://support.microsoft.com/?kbid=555017
Is that really necessary? it mentions non-domain web environments? all
servers are on the same domain. Seems lengthy for what I imagine to be a
very simple task.
[vbcol=seagreen]
> http://www.microsoft.com/technet/pr...ds/default.mspx[/vbco
l]
A tad more direction would help, there's hundreds of downloads! (it does
have the latest service pack)
cheers,
Chris

ASP cannot run stored proc until the web user has run the proc in Query Analyzer

I have an ASP that has been working fine for several months, but it
suddenly broke. I wonder if windows update has installed some security
patch that is causing it.

The problem is that I am calling a stored procedure via an ASP
(classic, not .NET) , but nothing happens. The procedure doesn't work,
and I don't get any error messages.

I've tried dropping and re-creating the user and permissions, to no
avail. If it was a permissions problem, there would be an error
message. I trace the calls in Profiler, and it has no complaints. The
database is getting the stored proc call.

I finally got it to work again, but this is not a viable solution for
our production environment:

1. response.write the SQL call to the stored procedure from the ASP
and copy the text to the clipboard.
2. log in to QueryAnalyzer using the same user as used by the ASP.
3. paste and run the SQL call to the stored proc in query analyzer.

After I have done this, it not only works in Query Analyzer, but then
the ASP works too. It continues to work, even after I reboot the
machine. This is truly bizzare and has us stumped. My hunch is that
windows update installed something that has created this issue, but I
have not been able to track it down.central_scrutinizer,

Does the ASP page hang, timeout or just return with no results? If it hangs
or times out, this may be happening:

1. The command is executed from the ASP page.
2. SQL Server needs to allocate more disk space (data or log) and performs
an autogrow of a large amount of disk space. This could take an extended
period of time.
3. The user cancels the ASP page or the page times out.
4. SQL Server cancels the transaction and also cancels the need for
additional disk space.
5. If steps 1-4 are repeated, you get the same result.
6. A user runs the stored procedure in QA allowing it to finish.
7. SQL Server allocates the addional space.
8. The ASP page now runs fine because the space has been allocated (until
the next time the database needs to allocate more space).

-- Bill

1. We would run the stored
"central_scrutinizer" <cbellur@.hotmail.comwrote in message
news:1172185833.914945.318670@.m58g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

>I have an ASP that has been working fine for several months, but it
suddenly broke. I wonder if windows update has installed some security
patch that is causing it.
>
The problem is that I am calling a stored procedure via an ASP
(classic, not .NET) , but nothing happens. The procedure doesn't work,
and I don't get any error messages.
>
I've tried dropping and re-creating the user and permissions, to no
avail. If it was a permissions problem, there would be an error
message. I trace the calls in Profiler, and it has no complaints. The
database is getting the stored proc call.
>
I finally got it to work again, but this is not a viable solution for
our production environment:
>
1. response.write the SQL call to the stored procedure from the ASP
and copy the text to the clipboard.
2. log in to QueryAnalyzer using the same user as used by the ASP.
3. paste and run the SQL call to the stored proc in query analyzer.
>
After I have done this, it not only works in Query Analyzer, but then
the ASP works too. It continues to work, even after I reboot the
machine. This is truly bizzare and has us stumped. My hunch is that
windows update installed something that has created this issue, but I
have not been able to track it down.
>

Tuesday, March 20, 2012

ASP .NET Application is Hanging when number of user grows

Hi,

Asp.net 2.0 (VB) application with Sql server 2000 Installed in windows 2000 professional server.Only less than 10 users using this application.

The problem is sometimes the application didn't response, it's very slow to get the information and after sometimes its never responding it showing hourclass.

I used Helper class (Application Block). Since Sql Server 2000 doesn't have the MARS Function, i have manually close the connection and opening again everytime.

Any idea?. Thanks in advance.

Help Class Modified Code:

--

Code :

' If the provided connection is not open, we will open it

If connection.State <> ConnectionState.Open Then

connection.Open()

mustCloseConnection = True

Else

mustCloseConnection = False

End If

Data ObjectBase :

'The transaction will call this method and also check the connection status

Public Sub BeginTransaction()

Try

If Not (myTransaction Is Nothing) Then

'Throw New Exception(ConfigManager.ReadFromXml("msg_DataAccess_Begin_trans"))

Throw New Exception("Transaction Error in Begin")

End If

If ourConnection.State <> ConnectionState.Open Then

ourConnection.Open()

myMustClose = True

Else

myMustClose = False

End If

myTransaction = ourConnection.BeginTransaction()

Catch ex As Exception

'Throw New BRSDatabaseException(ex.Message, ex)

Throw ex

End Try ''''

End Sub

Sounds like you need to determine what the bottleneck is. It could any number of things from the network, memory, hardware.

Are there other databases on this server in use?

How many records are being returned from sql server?

Are the tables that are being hit indexed?

I'd have the sql server dba monitor usage on the server in question.

|||I don't think it is SQL Server or Asp.net Win2k Pro concurrent users is five which means you need Small Business Server.|||

Hi Anthony Martin,

Yes, In this server there are about 3 applications running.

Very few records only returning (100 records)

We set only the primary key index.

is there any problem with connection closing in the object base class?

|||

I can't really speak on whether or not the .NET code is the issue. I have more experience with database tuning.

What do the query plans look like for the queries the application is using?

Are there large table index scans?

Try running sp_who2 or select * from sys.dm_db_exec_requests to monitor system usage/performance

|||

This is the output for sp_who2 in Sql Server 2000 Database.

1 BACKGROUND sa . . NULL LAZY WRITER 21688 0 06/14 17:57:59 1
2 sleeping sa . . NULL LOG WRITER 200766 0 06/14 17:57:59 2
3 BACKGROUND sa . . NULL LOCK MONITOR 1203 0 06/14 17:57:59 3
4 BACKGROUND sa . . master SIGNAL HANDLER 47 0 06/14 17:57:59 4
5 BACKGROUND sa . . master TASK MANAGER 0 849 06/14 17:57:59 5
6 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 6
7 sleeping sa . . NULL CHECKPOINT SLEEP 252156 17092 06/14 17:57:59 7
8 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 8
9 BACKGROUND sa . . master TASK MANAGER 0 1595 06/14 17:57:59 9
10 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 10
11 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 11
12 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 12
13 BACKGROUND sa . . master TASK MANAGER 0 388 06/14 17:57:59 13
14 BACKGROUND sa . . master TASK MANAGER 0 2129 06/14 17:57:59 14
15 BACKGROUND sa . . master TASK MANAGER 0 2176 06/14 17:57:59 15
17 BACKGROUND sa . . master TASK MANAGER 0 517 06/14 17:57:59 17
51 sleeping NT AUTHORITY\SYSTEM W2K92 . msdb AWAITING COMMAND 62 37 06/14 17:58:37 SQLAgent - Generic Refresher 51
52 sleeping NT AUTHORITY\SYSTEM W2K92 . msdb AWAITING COMMAND 1192429 29 09/13 12:57:53 SQLAgent - Alert Engine 52
53 sleeping WCAS PCOFFNONGGK8881 . WCASR2 AWAITING COMMAND 61 16 09/13 11:53:43 TESS 53
54 sleeping SA PCOFFNCHANWCS81 . TEMISCS AWAITING COMMAND 578 8 09/13 12:48:39 Temis-CS 54
55 sleeping SA PCOFFNHONGHSC81 . TEMISCS AWAITING COMMAND 218 3 09/13 12:07:14 Temis-CS 55
56 sleeping SA PCOFFNCHANWCS81 . TEMISCS AWAITING COMMAND 2080 228 09/13 12:49:45 Temis-CS 56
57 sleeping TESS W2K92 . TESS AWAITING COMMAND 29175 3 09/13 12:55:11 .Net SqlClient Data Provider 57
58 sleeping W2K92\w2k92_remote W2K92 . TESS AWAITING COMMAND 63 5 09/13 12:49:03 MS SQLEM 58
59 RUNNABLE W2K92\w2k92_remote W2K92 . TESS SELECT INTO 156 9 09/13 12:58:00 SQL Query Analyzer 59
60 sleeping TESS W2K92 . TESS AWAITING COMMAND 5549 0 09/13 12:58:02 .Net SqlClient Data Provider 60
61 sleeping sa W2K92 . WCASR2 AWAITING COMMAND 9422 408 09/13 12:57:57 Microsoft(R) Windows (R) 2000 Operating System 61
62 sleeping sa W2K92 . WCASR2 AWAITING COMMAND 1781 113 09/13 12:57:57 Microsoft(R) Windows (R) 2000 Operating System 62

ASP .NET Application is Hanging when number of user grows

Hi,

Asp.net 2.0 (VB) application with Sql server 2000 Installed in windows 2000 professional server.Only less than 10 users using this application.

The problem is sometimes the application didn't response, it's very slow to get the information and after sometimes its never responding it showing hourclass.

I used Helper class (Application Block). Since Sql Server 2000 doesn't have the MARS Function, i have manually close the connection and opening again everytime.

Any idea?. Thanks in advance.

Help Class Modified Code:

--

Code :

' If the provided connection is not open, we will open it

If connection.State <> ConnectionState.Open Then

connection.Open()

mustCloseConnection = True

Else

mustCloseConnection = False

End If

Data ObjectBase :

'The transaction will call this method and also check the connection status

Public Sub BeginTransaction()

Try

If Not (myTransaction Is Nothing) Then

'Throw New Exception(ConfigManager.ReadFromXml("msg_DataAccess_Begin_trans"))

Throw New Exception("Transaction Error in Begin")

End If

If ourConnection.State <> ConnectionState.Open Then

ourConnection.Open()

myMustClose = True

Else

myMustClose = False

End If

myTransaction = ourConnection.BeginTransaction()

Catch ex As Exception

'Throw New BRSDatabaseException(ex.Message, ex)

Throw ex

End Try ''''

End Sub

Sounds like you need to determine what the bottleneck is. It could any number of things from the network, memory, hardware.

Are there other databases on this server in use?

How many records are being returned from sql server?

Are the tables that are being hit indexed?

I'd have the sql server dba monitor usage on the server in question.

|||I don't think it is SQL Server or Asp.net Win2k Pro concurrent users is five which means you need Small Business Server.|||

Hi Anthony Martin,

Yes, In this server there are about 3 applications running.

Very few records only returning (100 records)

We set only the primary key index.

is there any problem with connection closing in the object base class?

|||

I can't really speak on whether or not the .NET code is the issue. I have more experience with database tuning.

What do the query plans look like for the queries the application is using?

Are there large table index scans?

Try running sp_who2 or select * from sys.dm_db_exec_requests to monitor system usage/performance

|||

This is the output for sp_who2 in Sql Server 2000 Database.

1 BACKGROUND sa . . NULL LAZY WRITER 21688 0 06/14 17:57:59 1
2 sleeping sa . . NULL LOG WRITER 200766 0 06/14 17:57:59 2
3 BACKGROUND sa . . NULL LOCK MONITOR 1203 0 06/14 17:57:59 3
4 BACKGROUND sa . . master SIGNAL HANDLER 47 0 06/14 17:57:59 4
5 BACKGROUND sa . . master TASK MANAGER 0 849 06/14 17:57:59 5
6 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 6
7 sleeping sa . . NULL CHECKPOINT SLEEP 252156 17092 06/14 17:57:59 7
8 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 8
9 BACKGROUND sa . . master TASK MANAGER 0 1595 06/14 17:57:59 9
10 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 10
11 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 11
12 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 12
13 BACKGROUND sa . . master TASK MANAGER 0 388 06/14 17:57:59 13
14 BACKGROUND sa . . master TASK MANAGER 0 2129 06/14 17:57:59 14
15 BACKGROUND sa . . master TASK MANAGER 0 2176 06/14 17:57:59 15
17 BACKGROUND sa . . master TASK MANAGER 0 517 06/14 17:57:59 17
51 sleeping NT AUTHORITY\SYSTEM W2K92 . msdb AWAITING COMMAND 62 37 06/14 17:58:37 SQLAgent - Generic Refresher 51
52 sleeping NT AUTHORITY\SYSTEM W2K92 . msdb AWAITING COMMAND 1192429 29 09/13 12:57:53 SQLAgent - Alert Engine 52
53 sleeping WCAS PCOFFNONGGK8881 . WCASR2 AWAITING COMMAND 61 16 09/13 11:53:43 TESS 53
54 sleeping SA PCOFFNCHANWCS81 . TEMISCS AWAITING COMMAND 578 8 09/13 12:48:39 Temis-CS 54
55 sleeping SA PCOFFNHONGHSC81 . TEMISCS AWAITING COMMAND 218 3 09/13 12:07:14 Temis-CS 55
56 sleeping SA PCOFFNCHANWCS81 . TEMISCS AWAITING COMMAND 2080 228 09/13 12:49:45 Temis-CS 56
57 sleeping TESS W2K92 . TESS AWAITING COMMAND 29175 3 09/13 12:55:11 .Net SqlClient Data Provider 57
58 sleeping W2K92\w2k92_remote W2K92 . TESS AWAITING COMMAND 63 5 09/13 12:49:03 MS SQLEM 58
59 RUNNABLE W2K92\w2k92_remote W2K92 . TESS SELECT INTO 156 9 09/13 12:58:00 SQL Query Analyzer 59
60 sleeping TESS W2K92 . TESS AWAITING COMMAND 5549 0 09/13 12:58:02 .Net SqlClient Data Provider 60
61 sleeping sa W2K92 . WCASR2 AWAITING COMMAND 9422 408 09/13 12:57:57 Microsoft(R) Windows (R) 2000 Operating System 61
62 sleeping sa W2K92 . WCASR2 AWAITING COMMAND 1781 113 09/13 12:57:57 Microsoft(R) Windows (R) 2000 Operating System 62

ASP .NET Application is Hanging when number of user grows

Hi,

Asp.net 2.0 (VB) application with Sql server 2000 Installed in windows 2000 professional server.Only less than 10 users using this application.

The problem is sometimes the application didn't response, it's very slow to get the information and after sometimes its never responding it showing hourclass.

I used Helper class (Application Block). Since Sql Server 2000 doesn't have the MARS Function, i have manually close the connection and opening again everytime.

Any idea?. Thanks in advance.

Help Class Modified Code:

--

Code :

' If the provided connection is not open, we will open it

If connection.State <> ConnectionState.Open Then

connection.Open()

mustCloseConnection = True

Else

mustCloseConnection = False

End If

Data ObjectBase :

'The transaction will call this method and also check the connection status

Public Sub BeginTransaction()

Try

If Not (myTransaction Is Nothing) Then

'Throw New Exception(ConfigManager.ReadFromXml("msg_DataAccess_Begin_trans"))

Throw New Exception("Transaction Error in Begin")

End If

If ourConnection.State <> ConnectionState.Open Then

ourConnection.Open()

myMustClose = True

Else

myMustClose = False

End If

myTransaction = ourConnection.BeginTransaction()

Catch ex As Exception

'Throw New BRSDatabaseException(ex.Message, ex)

Throw ex

End Try ''''

End Sub

Sounds like you need to determine what the bottleneck is. It could any number of things from the network, memory, hardware.

Are there other databases on this server in use?

How many records are being returned from sql server?

Are the tables that are being hit indexed?

I'd have the sql server dba monitor usage on the server in question.

|||I don't think it is SQL Server or Asp.net Win2k Pro concurrent users is five which means you need Small Business Server.|||

Hi Anthony Martin,

Yes, In this server there are about 3 applications running.

Very few records only returning (100 records)

We set only the primary key index.

is there any problem with connection closing in the object base class?

|||

I can't really speak on whether or not the .NET code is the issue. I have more experience with database tuning.

What do the query plans look like for the queries the application is using?

Are there large table index scans?

Try running sp_who2 or select * from sys.dm_db_exec_requests to monitor system usage/performance

|||

This is the output for sp_who2 in Sql Server 2000 Database.

1 BACKGROUND sa . . NULL LAZY WRITER 21688 0 06/14 17:57:59 1
2 sleeping sa . . NULL LOG WRITER 200766 0 06/14 17:57:59 2
3 BACKGROUND sa . . NULL LOCK MONITOR 1203 0 06/14 17:57:59 3
4 BACKGROUND sa . . master SIGNAL HANDLER 47 0 06/14 17:57:59 4
5 BACKGROUND sa . . master TASK MANAGER 0 849 06/14 17:57:59 5
6 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 6
7 sleeping sa . . NULL CHECKPOINT SLEEP 252156 17092 06/14 17:57:59 7
8 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 8
9 BACKGROUND sa . . master TASK MANAGER 0 1595 06/14 17:57:59 9
10 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 10
11 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 11
12 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 12
13 BACKGROUND sa . . master TASK MANAGER 0 388 06/14 17:57:59 13
14 BACKGROUND sa . . master TASK MANAGER 0 2129 06/14 17:57:59 14
15 BACKGROUND sa . . master TASK MANAGER 0 2176 06/14 17:57:59 15
17 BACKGROUND sa . . master TASK MANAGER 0 517 06/14 17:57:59 17
51 sleeping NT AUTHORITY\SYSTEM W2K92 . msdb AWAITING COMMAND 62 37 06/14 17:58:37 SQLAgent - Generic Refresher 51
52 sleeping NT AUTHORITY\SYSTEM W2K92 . msdb AWAITING COMMAND 1192429 29 09/13 12:57:53 SQLAgent - Alert Engine 52
53 sleeping WCAS PCOFFNONGGK8881 . WCASR2 AWAITING COMMAND 61 16 09/13 11:53:43 TESS 53
54 sleeping SA PCOFFNCHANWCS81 . TEMISCS AWAITING COMMAND 578 8 09/13 12:48:39 Temis-CS 54
55 sleeping SA PCOFFNHONGHSC81 . TEMISCS AWAITING COMMAND 218 3 09/13 12:07:14 Temis-CS 55
56 sleeping SA PCOFFNCHANWCS81 . TEMISCS AWAITING COMMAND 2080 228 09/13 12:49:45 Temis-CS 56
57 sleeping TESS W2K92 . TESS AWAITING COMMAND 29175 3 09/13 12:55:11 .Net SqlClient Data Provider 57
58 sleeping W2K92\w2k92_remote W2K92 . TESS AWAITING COMMAND 63 5 09/13 12:49:03 MS SQLEM 58
59 RUNNABLE W2K92\w2k92_remote W2K92 . TESS SELECT INTO 156 9 09/13 12:58:00 SQL Query Analyzer 59
60 sleeping TESS W2K92 . TESS AWAITING COMMAND 5549 0 09/13 12:58:02 .Net SqlClient Data Provider 60
61 sleeping sa W2K92 . WCASR2 AWAITING COMMAND 9422 408 09/13 12:57:57 Microsoft(R) Windows (R) 2000 Operating System 61
62 sleeping sa W2K92 . WCASR2 AWAITING COMMAND 1781 113 09/13 12:57:57 Microsoft(R) Windows (R) 2000 Operating System 62

sql

ASP .NET Application is Hanging when number of user grows

Hi,

Asp.net 2.0 (VB) application with Sql server 2000 Installed in windows 2000 professional server.Only less than 10 users using this application.

The problem is sometimes the application didn't response, it's very slow to get the information and after sometimes its never responding it showing hourclass.

I used Helper class (Application Block). Since Sql Server 2000 doesn't have the MARS Function, i have manually close the connection and opening again everytime.

Any idea?. Thanks in advance.

Help Class Modified Code:

--

Code :

' If the provided connection is not open, we will open it

If connection.State <> ConnectionState.Open Then

connection.Open()

mustCloseConnection = True

Else

mustCloseConnection = False

End If

Data ObjectBase :

'The transaction will call this method and also check the connection status

Public Sub BeginTransaction()

Try

If Not (myTransaction Is Nothing) Then

'Throw New Exception(ConfigManager.ReadFromXml("msg_DataAccess_Begin_trans"))

Throw New Exception("Transaction Error in Begin")

End If

If ourConnection.State <> ConnectionState.Open Then

ourConnection.Open()

myMustClose = True

Else

myMustClose = False

End If

myTransaction = ourConnection.BeginTransaction()

Catch ex As Exception

'Throw New BRSDatabaseException(ex.Message, ex)

Throw ex

End Try ''''

End Sub

Sounds like you need to determine what the bottleneck is. It could any number of things from the network, memory, hardware.

Are there other databases on this server in use?

How many records are being returned from sql server?

Are the tables that are being hit indexed?

I'd have the sql server dba monitor usage on the server in question.

|||I don't think it is SQL Server or Asp.net Win2k Pro concurrent users is five which means you need Small Business Server.|||

Hi Anthony Martin,

Yes, In this server there are about 3 applications running.

Very few records only returning (100 records)

We set only the primary key index.

is there any problem with connection closing in the object base class?

|||

I can't really speak on whether or not the .NET code is the issue. I have more experience with database tuning.

What do the query plans look like for the queries the application is using?

Are there large table index scans?

Try running sp_who2 or select * from sys.dm_db_exec_requests to monitor system usage/performance

|||

This is the output for sp_who2 in Sql Server 2000 Database.

1 BACKGROUND sa . . NULL LAZY WRITER 21688 0 06/14 17:57:59 1
2 sleeping sa . . NULL LOG WRITER 200766 0 06/14 17:57:59 2
3 BACKGROUND sa . . NULL LOCK MONITOR 1203 0 06/14 17:57:59 3
4 BACKGROUND sa . . master SIGNAL HANDLER 47 0 06/14 17:57:59 4
5 BACKGROUND sa . . master TASK MANAGER 0 849 06/14 17:57:59 5
6 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 6
7 sleeping sa . . NULL CHECKPOINT SLEEP 252156 17092 06/14 17:57:59 7
8 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 8
9 BACKGROUND sa . . master TASK MANAGER 0 1595 06/14 17:57:59 9
10 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 10
11 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 11
12 BACKGROUND sa . . master TASK MANAGER 0 0 06/14 17:57:59 12
13 BACKGROUND sa . . master TASK MANAGER 0 388 06/14 17:57:59 13
14 BACKGROUND sa . . master TASK MANAGER 0 2129 06/14 17:57:59 14
15 BACKGROUND sa . . master TASK MANAGER 0 2176 06/14 17:57:59 15
17 BACKGROUND sa . . master TASK MANAGER 0 517 06/14 17:57:59 17
51 sleeping NT AUTHORITY\SYSTEM W2K92 . msdb AWAITING COMMAND 62 37 06/14 17:58:37 SQLAgent - Generic Refresher 51
52 sleeping NT AUTHORITY\SYSTEM W2K92 . msdb AWAITING COMMAND 1192429 29 09/13 12:57:53 SQLAgent - Alert Engine 52
53 sleeping WCAS PCOFFNONGGK8881 . WCASR2 AWAITING COMMAND 61 16 09/13 11:53:43 TESS 53
54 sleeping SA PCOFFNCHANWCS81 . TEMISCS AWAITING COMMAND 578 8 09/13 12:48:39 Temis-CS 54
55 sleeping SA PCOFFNHONGHSC81 . TEMISCS AWAITING COMMAND 218 3 09/13 12:07:14 Temis-CS 55
56 sleeping SA PCOFFNCHANWCS81 . TEMISCS AWAITING COMMAND 2080 228 09/13 12:49:45 Temis-CS 56
57 sleeping TESS W2K92 . TESS AWAITING COMMAND 29175 3 09/13 12:55:11 .Net SqlClient Data Provider 57
58 sleeping W2K92\w2k92_remote W2K92 . TESS AWAITING COMMAND 63 5 09/13 12:49:03 MS SQLEM 58
59 RUNNABLE W2K92\w2k92_remote W2K92 . TESS SELECT INTO 156 9 09/13 12:58:00 SQL Query Analyzer 59
60 sleeping TESS W2K92 . TESS AWAITING COMMAND 5549 0 09/13 12:58:02 .Net SqlClient Data Provider 60
61 sleeping sa W2K92 . WCASR2 AWAITING COMMAND 9422 408 09/13 12:57:57 Microsoft(R) Windows (R) 2000 Operating System 61
62 sleeping sa W2K92 . WCASR2 AWAITING COMMAND 1781 113 09/13 12:57:57 Microsoft(R) Windows (R) 2000 Operating System 62

Asking userid and password while deploying reports

Hi All,

While deploying reports on the reports server, it is asking to supply user name and password. When I entered the same, it didn't accept them. What do I need to do? Is there any specific setting which I need to configure?

An immediate reply will be highly appreciated.

Thanks

Sekhar

check out the steps outlined here:

http://msdn2.microsoft.com/en-us/library/ms155802.aspx

and make sure that permissions have been set properly for the user

http://msdn2.microsoft.com/en-us/library/ms156014.aspx

|||To deploy the reports, you need to have specific permissions. the username and password you are giving may not belongs to administrator group. Just give username and password of the administrator of the deployment server.

Asking the user a question

Hello all,

I have a client with an application that they have purchased, it
stores its data on SQL server 2000 and so I am able to do reports and
some small VB apps that use the data. I can't however make any
significant changes to the app itself, just what it allows you to
configure.

The system records jobs, when a job is closed the client want a prompt
to pop-up asking if they want to record that the job is closed in a
special log file. I suggested that we use a checkbox (We can add
custom fields to the app) to record this, then I could write a trigger
that checks that field and adds it to the log file if it's 1, but no
they want a yes/no message box type thing popping up.

Is it possible to display (on the users screen) and get input back
from a yes/no message box in a SQL Server trigger? As far as I can
tell it isn't but it would be great if I were wrong.

Any help/suggestions greatly appreciated!!!

Thanks,

Bob.SQL Server can't invoke anything in your UI. That's something you have to do
in client-side code.

--
David Portas
SQL Server MVP
--|||Robert Hogan (busrhogan@.hotmail.com) writes:
> Is it possible to display (on the users screen) and get input back
> from a yes/no message box in a SQL Server trigger? As far as I can
> tell it isn't but it would be great if I were wrong.

In theory, yes. But for crying out loud, don't do it!

You could use sp_OAmethod and friends to run a remote OLE object
that would wait for the reponse.

But while waiting for user input - which could take several hours or
days - you are in the middle of a transaction, data will be uncommitted
and locks will be held. Could have sever impact on the situation.

A variant would be to have the OLE thing asynchronous, so that the
trigger does not wait for input, and the OLE thing would then update
the database itself.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||
"Robert Hogan" <busrhogan@.hotmail.com> wrote in message
news:eb62f112.0501171614.cb68c36@.posting.google.co m...
> Hello all,
> I have a client with an application that they have purchased, it
> stores its data on SQL server 2000 and so I am able to do reports and
> some small VB apps that use the data. I can't however make any
> significant changes to the app itself, just what it allows you to
> configure.
> The system records jobs, when a job is closed the client want a prompt
> to pop-up asking if they want to record that the job is closed in a
> special log file.

Well...
This is the problem with buying a package.
They do what the people wrote them guessed you wanted.
How close that is to what you do depends on how good he guessed.

> I suggested that we use a checkbox (We can add
> custom fields to the app) to record this, then I could write a trigger
> that checks that field and adds it to the log file if it's 1, but no
> they want a yes/no message box type thing popping up.

No chance.
You/They have 4 practical options:

1) Bung the field on and use a trigger to write the stuff as you suggest.

2) Contact the people wrote the package and pay them to make a custom
change.
If they're happy to do this then remember upgrades and expect to pay
through the nose for that confirmation box.

3) Re-write the package from scratch.
Probably financially unattractive unless they have a lot of reports and
customisation in mind.

4) Work out what that screen does and write one yourself that replaces it.
Some packages allow you to have custom screens, I'd guess maybe this
isn't one so maybe not so practical.
If that one screen and your other additions is all whoever closes jobs
uses then maybe it is a go-er.
> Is it possible to display (on the users screen) and get input back
> from a yes/no message box in a SQL Server trigger? As far as I can
> tell it isn't but it would be great if I were wrong.
> Any help/suggestions greatly appreciated!!!

Next time they buy a package..
Remember the hidden costs.
It's can be far cheaper to go for a bespoke app in the long run.

> Thanks,
> Bob.

--
Regards,
Andy O'Neillsql

asking for user's input before report generation - plz help?

Hi guys,
I am very new to Rep Services so need your help or suggestion:
Question: Let's say I have a very simple set of data, but before the
report is generated, userviewing the report has to enter a number and
then the report takes this number and subtracts from it a number
sitting in the database - and displayes the result in the report.
Let me explain. Let's say here's my data:
Item Bill
1 $30
2 $50
3 $45
Before the report is generated, a popup will come up, asking the user
to input a Total Bill on Paper Invoice $.
Then the report will show:
Internal Total: $125 (this is the number calculated from the data
table.
Total Bill on the Paper Invoice: $130 (this is the number that the
report viewer inputted)
TOTAL AMOUNT DUE: ($130) - ($125) = $5 (this is the difference
between user's inputted number and the number from the table.
How would I create a report such as the above so that prior to report
generating, a popup would come up asking for the user to input $130 and
then the report would take the difference between user's input number
and the number sitting in the database table?
This should be very easy, but since I'm so new, I need your help.
Thanks in advance.The HTML report header can't pop-up a window to prompt users for input but
you can use a parameter that will show-up in the header toolbar. Add a
report parameter and then reference it in an expression as (textbox value)
=Parameters!TotalBill.Value-Fields!InternalTotal.Value
"Kartuli" <kartuli.com@.gmail.com> wrote in message
news:1114454790.571054.87820@.f14g2000cwb.googlegroups.com...
> Hi guys,
> I am very new to Rep Services so need your help or suggestion:
> Question: Let's say I have a very simple set of data, but before the
> report is generated, userviewing the report has to enter a number and
> then the report takes this number and subtracts from it a number
> sitting in the database - and displayes the result in the report.
> Let me explain. Let's say here's my data:
> Item Bill
> 1 $30
> 2 $50
> 3 $45
> Before the report is generated, a popup will come up, asking the user
> to input a Total Bill on Paper Invoice $.
> Then the report will show:
> Internal Total: $125 (this is the number calculated from the data
> table.
> Total Bill on the Paper Invoice: $130 (this is the number that the
> report viewer inputted)
> TOTAL AMOUNT DUE: ($130) - ($125) = $5 (this is the difference
> between user's inputted number and the number from the table.
> How would I create a report such as the above so that prior to report
> generating, a popup would come up asking for the user to input $130 and
> then the report would take the difference between user's input number
> and the number sitting in the database table?
> This should be very easy, but since I'm so new, I need your help.
> Thanks in advance.
>

Asking for User input mid-execution

Is it possible to ask for user input in the middle of a stored procedure execution?

What I have is a single procedure that is going to do some deletes, and I want to receive confirmation from the user that they're ok with actually going through with the delete.

The procedure is being run from a Query Analyzer-type interface, and I have no access to tie proper code into the application this is being run from (hence why I'm trying to add some user-based conditional logic).

Thanks in advance for any assistance!1

No.

asking for SQL query

i am developing a account statement so when the user click on the link to view the February link it will show the transaction from Jan - Feb ,
how to format it to a query
i have the sample fo the following table:

ID trans_desc trans_date
-------------
1 testing 1/9/2003 11:33:00 AM
2 testing1 2/9/2003 11:33:00 AM
3 testing2 1/9/2004 11:33:00 AM

how to i extract the transaction description month from the month Jan-Feb . how to i do for the SQL queryIf there are 50 people on this forum, you'll get 50 different ways to do this. Here is one:

declare @.SelectedDate datetime
set @.SelectedDate = '2003-02-15'

select *
from YourTable
where trans_date >= convert(char(4), @.SelectedDate, 120)+'-01-01'
and trans_date < dateadd(month, 1, convert(char(7), @.SelectedDate, 120)+'-01')

Monday, March 19, 2012

ask user to select excel

Dear friends, can anyone please tell me that how at the time when user executes the package i can ask a user to choose the datasource excel sheet and what are the constraints i have to take care of in the integration package desing.

thanks,

If you'd like to ask user something, then, I'm afraid, you shoud write your own client application, cause SQL Server does provide nothing to bild any interfaces.
|||

dear Sergey Gavrilenko,

is there any way that before running the integration service package i can ask the user to enter the file path of excel that he wants to use as the souce file.

if not easy way then please tell me the only possible way, even if i have to use visual studio .net to get the same.

thanks,

ask help for licence problem

I am using asp and crystal report to create a report on web.

However, due to the licence problem, I need to clear the user's login session info each time after they access the report.

The probelm, when user returns to other page, since the session info is clear, user needs to login again.

Can anyone help me to solve this problem? Thanks a lot!It seems problem in Session valriable. Increase the lifetime of session

Sunday, March 11, 2012

AS400 DB2 connection strings

I am trying to construct a connection string via iSeries OleDb provider. The default list of libraries on the AS400 for my user is fine for production. But in test scenarios the code/data libraries are rolled out through a sequence of test libraries. How do I specify the additional libraries for testing.

I connect fine and can execute sql. the statements like insert into TestLibrary.Table work fine, but the associated trigger code isn't called.

Would it be better to use the .Net Connection set of classes instead. I switched from ODBC to OleDb because of assumed thread safety issues.I don't understand what you're looking for. Can you be more specific? If trigger code isn't called, how is that an SSIS issue?|||Maybe not.

The problem is building a connection string to communicate withe as400 db2. I found other threads in this forum dealing with other issues on this connectivity. The point about the trigger code not executing is because the library on the as400 that contains the trigger code is not part of the default library list for the connecting user.

the question is how to construct the connection string to add additional libraries into the scope of the connection. I was able to do so using ODBC. I wanted to use either the OleDb or the ADO clone iSeries connection stuff to do it as well.|||This link might help: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1061900&SiteID=1

Thursday, March 8, 2012

AS2005 Slow initial cube opening

Hi

We are having a problem in our AS2005 cubes that the initial openeing of the cubes is exceptionally slow. When the user connects though ProClarity, or I open the cube in the designer, the first report or first display of data takes about 2 minutes to return. Once it is open, the next query that you run is fine. If you exit the application, and go back in, you have to wait again for the first report.

This is very annoying to the users and frustrating for me as I cannot see anything that could be causing this.
We are running Windows Server 2003 x64 edition SP1 with SQL AS2005 x64 SP1.

Has anyone seen this before or can point me in the right direction where to look to solve this issue.

Thanks
Michael

Are you running ProClarity Professional directly againts the cube or are you using http access though ProClarity Analytics Server?

Caching of data will take some time, after a full process or restart of the server(the first user will have to pay the price of waiting) but two minutes seems to be to much. My customer run on a less powerful server than yours and the client access is though Citrix. In the morning our responstime is 30 sec to one minute.

Can you run profiler on SSAS2005 and see what happens during these two minutes?

Regards

Thomas Ivarsson

|||

we are accessing the cube directly, not using http.

The issue is that The does not only occure on the first query of the morning after a process, but on every new login during the day. I did a trace on the AS DB and there were a lot of "Discover Begin" and "End" EventClass events occuring before the MDX query was run. The were doing a lot of "10 - MDSCHEMA_MEMBERS" EventSubclass.

Could this be caused by the way the Dimensions are setup?

Thanks

Michael

|||

It can be something regarding dimension design. Do you have attribut relations defined in user hierarchies and are you using rigid relationship types? Check this Blog for more information: http://blogs.conchango.com/christianwade/archive/2006/07/12/AS-2005-Optimization-Experiences.aspx

Regards

Thomas Ivarsson

|||

Thanks, we are busy looking at a redesign of this Cube. This was designed on the Sept CTP last year, before there was any blogs about optimisations or anything like that, hence the bad Dimension design. I really just wanted to ensure that there wasn't something else out there that could be causing this.

Regards
Michael

AS2005 and Excel

Hi all

i am trying to connect to a AS2005 cube from excel.

On my computer (Excel2003+sp1) i am able to see and broswe the cube.On the user's Pc (excel2003+sp1) I istalled the msolap9.dll but i got this error when i try to connect to the OLAPserver:

"Unable to connect to data source.Reason: Unable to locate database server"

Both me and the user are in the Cube's Role Membership.....

Any idea?

Thx in advance

Are you using this addin or not?: http://www.microsoft.com/downloads/details.aspx?FamilyId=DAE82128-9F21-475D-88A4-4B6E6C069FF0&displaylang=en

The message "Unable to connect to data source.Reason: Unable to locate database server".,can mean that the service is down or you can have a firewall problem.

Many causes. Can you supply more details?

Regards

Thomas Ivarsson

|||

Thank you so much Thomas, that is was i forgot to install....

thx

Wednesday, March 7, 2012

AS hangs when running a complex mdx query

Hi all,

I am having a problem with Analysis Services. Currently we are developing an analysis application that enables a user to view up to 5 year survival for patients.

I have written the following MDX to perform the calculated measure:

Code Snippet

/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;


//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
// SURVIVAL


// Censor flag = 1 if censored, 0 if noncensored (or true failure),
// NULL if there is data error (death date <= diagnosis date)


CREATE MEMBER CURRENTCUBE.[MEASURES].[N Noncensored Deaths]
AS [Measures].[N Total Deaths] - [Measures].[N Censored Deaths],
FORMAT_STRING = "#",
VISIBLE = 0 ;


CREATE MEMBER CURRENTCUBE.[MEASURES].[Number at risk]
AS 0,
VISIBLE = 1;
SCOPE ([Measures].[Number at risk]); ([Survival Time].Members(1): Null) =
(
Case

/*

At the first survival time (defined as Null, i.e. 1st row with "Blank" time,
when there is no previous month; PrevMember is empty):

Number at risk is simply total number of valid death dates (both censored and uncensored)
in the dataset, which is the total number of patients with censor flag values of
either 0 or 1 (not null), i.e. Number at risk at t == 0 (date of diagnosis).

NOTE: Death dates are right-censored at 01 June 2006 - people who haven't died
by this date are censored and assigned a death date of June 1, 2006.

The censor flag is set to null only when death date is same as or EARLIER than
date of diagnosis, i.e. excludes patients diagnosed during autopsy.

*/

When IsEmpty( [Survival Time].CurrentMember.PrevMember )

Then ( Root( [Survival Time] ), [N Total Deaths] )

/*
This is the survival censor count at the top ("root") level of survival time,
*/


Else // At subsequent survival times ( t > 0, censor <> null ), Number at risk is:

(
// Number at risk from previous month,
// minus total number of deaths (both censored and uncensored)
// during current month

( [Survival Time].CurrentMember.PrevMember, [Number at risk] )
- [N Total Deaths]

)

End
);
END SCOPE;

//--

CREATE MEMBER CURRENTCUBE.[MEASURES].[Survival]
AS 100,
FORMAT_STRING = '0.0',
VISIBLE = 1;
SCOPE ([Measures].[Survival]); ([Survival Time].Members(1): Null) =
(
Case

// At the first survival time (defined as Null, i.e. 1st row with "Blank" time):
When IsEmpty( [Survival Time].CurrentMember.PrevMember )

Then (
(
(
( Root([Survival Time]),[N Total Deaths] ) - [N Total Deaths] ) / ( (Root([Survival Time]), [N Total Deaths] ) - ([Survival Time],[N Censored Deaths])
)
)*100
)

Else // At subsequent survival times ( t > 0, censor <> null ):
(
Case

// If everyone's dead (at right end of time(x) axis)
When [Number at risk] = 0

// Then use survival from previous month (PrevMember)
Then "Censored" //( [Survival Time].CurrentMember.PrevMember, [Survival] )

Else (
(
// Number at risk from previous month, minus true failures (noncensored deaths),
// divided by Number at risk from previous month ...
(
( ([Survival Time].CurrentMember.PrevMember, [Number at risk] ) - ( [Survival Time].CurrentMember,[N Noncensored Deaths]) ) /
([Survival Time].CurrentMember.PrevMember, [Number at risk]
)
)
// then multiplied by survival from previous month
* ([Survival Time].CurrentMember.PrevMember, [Survival])
)
)
End
)
End
); END SCOPE;

When I put the Calculated Measure then the survival time dimension in the x axis in the pivot table, it works fine. But when I put a dimension in the filter and choose multiple items (not all and not only one) it tries to build and run the query but seems to hang.

Has anyone else experienced this sort of thing before?

Would it be something to do with the MDX?

I have been struggling with this for a while and not been able to work it out. ANY suggestions would be fantastic.

If you need further information, let me know.

Steve

I have not gone through your code in too much detail, but you main issue is going to be the .CurrentMember function.

When you have mulitple members on the WHERE clause (which is what happens when you filter by more than one member), you do not have a single current member, you actually have a set of current members. SSAS 2005 just does not handle this well. See this blog post for more details: http://sqljunkies.com/WebLog/mosha/archive/2005/11/18/multiselect_friendly_mdx.aspx it might give you some hints on how to alter your code.

|||

Darren,

Thanks for your reply. I tried going to that blog post but couldn't open the page. Are you able to provide another location for the blog?

Cheers,

Stephen

|||

Yeah, I found out that the whole of sqljunkies.com appears to have gone off the air, no word on when or if it will return.

You can find an archived copy of this post in the web archive at http://web.archive.org/web/20070515145719/http://www.sqljunkies.com/WebLog/mosha/archive/2005/11/18/multiselect_friendly_mdx.aspx

|||

Thanks Darren. I found the blog but am not sure how to fix my code.

I actually tried a couple of things with no success. I removed the .CurrentMember from my code (see code snippet) and it worked for single select queries but it still hangs for multiselect.

Code Snippet

/*

The CALCULATE command controls the aggregation of leaf cells in the cube.

If the CALCULATE command is deleted or modified, the data within the cube is affected.

You should edit this command only if you manually specify how the cube is aggregated.

*/

CALCULATE;

//**************************************************************************************

//**************************************************************************************

//**************************************************************************************

// SURVIVAL

// Censor flag = 1 if censored, 0 if noncensored (or true failure),

// NULL if there is data error (death date <= diagnosis date)

CREATE MEMBER CURRENTCUBE.[MEASURES].[N Noncensored Deaths]

AS [Measures].[N Total Deaths] - [Measures].[N Censored Deaths],

FORMAT_STRING = "#",

VISIBLE = 0 ;

CREATE MEMBER CURRENTCUBE.[MEASURES].[Number at risk]

AS 0,

VISIBLE = 1;

SCOPE ([Measures].[Number at risk]); ([Survival Time].Members(1): Null) =

(

Case

/*

At the first survival time (defined as Null, i.e. 1st row with "Blank" time,

when there is no previous month; PrevMember is empty):

Number at risk is simply total number of valid death dates (both censored and uncensored)

in the dataset, which is the total number of patients with censor flag values of

either 0 or 1 (not null), i.e. Number at risk at t == 0 (date of diagnosis).

NOTE: Death dates are right-censored at 01 June 2006 - people who haven't died

by this date are censored and assigned a death date of June 1, 2006.

The censor flag is set to null only when death date is same as or EARLIER than

date of diagnosis, i.e. excludes patients diagnosed during autopsy.

*/

When IsEmpty([Survival Time].PrevMember )

Then ( Root( [Survival Time] ), [N Total Deaths] )

/*

This is the survival censor count at the top ("root") level of survival time,

*/

Else // At subsequent survival times ( t > 0, censor <> null ), Number at risk is:

(

// Number at risk from previous month,

// minus total number of deaths (both censored and uncensored)

// during current month

([Survival Time].PrevMember, [Number at risk] )

- [N Total Deaths]

)

End

);

END SCOPE;

//--

CREATE MEMBER CURRENTCUBE.[MEASURES].[Survival]

AS 100,

FORMAT_STRING = '0.0',

VISIBLE = 1;

SCOPE ([Measures].[Survival]); ([Survival Time].Members(1): Null) =

(

Case

// At the first survival time (defined as Null, i.e. 1st row with "Blank" time):

When IsEmpty([Survival Time].PrevMember )

Then (

(

(

( Root([Survival Time]),[N Total Deaths] ) - [N Total Deaths] ) / ( (Root([Survival Time]), [N Total Deaths] ) - ([Survival Time],[N Censored Deaths])

)

)*100

)

Else // At subsequent survival times ( t > 0, censor <> null ):

(

Case

// If everyone's dead (at right end of time(x) axis)

When [Number at risk] = 0

// Then use survival from previous month (PrevMember)

Then "Censored" //( [Survival Time].CurrentMember.PrevMember, [Survival] )

Else (

(

// Number at risk from previous month, minus true failures (noncensored deaths),

// divided by Number at risk from previous month ...

(

( ([Survival Time].PrevMember, [Number at risk] ) - ([Survival Time],[N Noncensored Deaths]) ) /

([Survival Time].PrevMember, [Number at risk]

)

)

// then multiplied by survival from previous month

* ([Survival Time].PrevMember, [Survival])

)

)

End

)

End

); END SCOPE;

I appreciate you helping me on this.

Cheers,

Steve

|||

Sorry, I was not entirely clear. While removing the explicit CurrentMember calls is good, there is still an implied one for the .PrevMember calls. The query engine still needs a single member context to calculate a PrevMember. There is a way to do this, but it has the unforutnate side effect of slowing down your calc for single member select. What you would need to do is to wrap your case statement (the bit after the equals inside your scope statement) as follows:

GENERATE( EXISTING [Survival Time].Members, <case statement> )

The Existing operator returns the set of one or more survival time members that are in context for the current query and the generate function essentially loops over the set and evaluates the case statement for each one. The results are then aggregated together and returned.

|||

Hi Darren,

My guess is that multi-select is not occurring on the [Survival Time] dimension, otherwise there should have been an error like: "The MDX function CURRENTMEMBER failed because the coordinate for .. attribute contains a set", as mentioned in Mosha's blog. The scenario described by Steve suggests that [Survival Time] is on columns, and some other dimension(s) (which aren't mentioned in the script) are being multi-selected in the filter field - but Steve could confirm this? It might be useful to know the client tool (presumably some flavor of Excel).

|||

Hi Deepak,

You are right. We are selecting dimensions such as age, location etc.

We are using Dundas for our client tool.

Cheers,

Steve

|||

Steve,

Thanks for the clarification - to confirm the exact Dundas product, is it Dundas Chart for .NET - OLAP Services?

|||

Deepak,

It is Dundas Chart for .NET - OLAP Service (5.5).

Thanks,

Steve

|||

Here are some initial ideas for improving script performance - with more information, these could be elaborated:

It might be possible to handle the first [Survival Time] member using static scoping, rather than a run-time case statement, as discussed in this article. What is the structure of [Survival Time] - how many levels does it have?

Not sure which measures are cube vs. calculated, but if [Measures].[N Total Deaths] and [Measures].[N Censored Deaths] are cube measures, [MEASURES].[N Noncensored Deaths] could be implemented as a cube measure as well. Could you describe the fact table/measure group and associated measures?

Using running sum calculations which leverage block computation - it looks like [MEASURES].[Number at risk] could be implemented using a running sum of [N Total Deaths]?

|||

Hi Deepak,

I have run the query when it works and when it hangs. And the following MDX queries are what resulted:

Working:

SELECT NON EMPTY {{[Survival Time].[Survival Time].[All]}, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS, NON EMPTY { Crossjoin({{[Cancer].[Cancers].[All]}, [Cancer].[Cancers].[Stream].members}, VISUALTOTALS({ [Measures].[Survival] }) ) } ON ROWS FROM [Survival] WHERE ( ( [Year of diagnosis].[Year of diagnosis].[All] ), ( [Age at diagnosis].[Age].[All] ), ( [Sex].[Sex].[All] ), ( [Residence].[Residence].[All] ), ( [Rurality].[Rurality].[All] ) )

Not Working (hangs/uses up all resources):

SELECT NON EMPTY {{[Survival Time].[Survival Time].[All]}, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS, NON EMPTY { Crossjoin({{[Cancer].[Cancers].[All]}, [Cancer].[Cancers].[Stream].members}, VISUALTOTALS({ [Measures].[Survival] }) ) } ON ROWS FROM [Survival] WHERE ( VISUALTOTALS({ [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2001], [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2003] }), ( [Age at diagnosis].[Age].[All] ), ( [Sex].[Sex].[All] ), ( [Residence].[Residence].[All] ), ( [Rurality].[Rurality].[All] ) )

Thanks for your help so fay.

Steve

|||

Hi Steve,

Just wanted to clarify a couple of things:

- Is [Survival Time] just a single level (month) dimension - and approx. how many members?

- The VisualTotals() seem to be superfluous, so could you check whether the 2nd query still hangs without VisualTotals(), like:

SELECT NON EMPTY {{[Survival Time].[Survival Time].[All]}, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS, NON EMPTY { Crossjoin({{[Cancer].[Cancers].[All]}, [Cancer].[Cancers].[Stream].members}, { [Measures].[Survival] } ) } ON ROWS FROM [Survival] WHERE ( { [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2001], [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2003] }, ( [Age at diagnosis].[Age].[All] ), ( [Sex].[Sex].[All] ), ( [Residence].[Residence].[All] ), ( [Rurality].[Rurality].[All] ) )

|||

Hi Deepak,

The [Survival Time] dimension is a single level dimension. It is a count of months from a starting date to a death date.

I also ran the query from the browser in SQL Server Management Studio which dropped Visual Totals and it still hung.

Thanks again for your help.

Cheers,

Steve

|||

I'm not sure you need any of the VisualTotals functions. And unless you have overriden the default member settings on some of your dimensions, explicit referencing the default members would be redundant. The following two queries should be equivalent to the last 2 that you posted.

SELECT

NON EMPTY

{

{[Survival Time].[Survival Time].[All]}

, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS

, NON EMPTY

{[Cancer].[Cancers].[All]

, [Cancer].[Cancers].[Stream].members}

ON ROWS

FROM [Survival]

WHERE

( [Measures].[Survival],[Year of diagnosis].[Year of diagnosis].[All] );

--Was not Working

SELECT

NON EMPTY

{

{[Survival Time].[Survival Time].[All]}

, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS

, NON EMPTY

{[Cancer].[Cancers].[All]

, [Cancer].[Cancers].[Stream].members}

ON ROWS

FROM [Survival]

WHERE ( [Measures].[Survival],

{ [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2001]

, [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2003] })

AS hangs when running a complex mdx querie

Hi all,

I am having a problem with Analysis Services. Currently we are developing an analysis application that enables a user to view up to 5 year survival for patients.

I have written the following MDX to perform the calculated measure:

Code Snippet

/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;


//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
// SURVIVAL


// Censor flag = 1 if censored, 0 if noncensored (or true failure),
// NULL if there is data error (death date <= diagnosis date)


CREATE MEMBER CURRENTCUBE.[MEASURES].[N Noncensored Deaths]
AS [Measures].[N Total Deaths] - [Measures].[N Censored Deaths],
FORMAT_STRING = "#",
VISIBLE = 0 ;


CREATE MEMBER CURRENTCUBE.[MEASURES].[Number at risk]
AS 0,
VISIBLE = 1;
SCOPE ([Measures].[Number at risk]); ([Survival Time].Members(1): Null) =
(
Case

/*

At the first survival time (defined as Null, i.e. 1st row with "Blank" time,
when there is no previous month; PrevMember is empty):

Number at risk is simply total number of valid death dates (both censored and uncensored)
in the dataset, which is the total number of patients with censor flag values of
either 0 or 1 (not null), i.e. Number at risk at t == 0 (date of diagnosis).

NOTE: Death dates are right-censored at 01 June 2006 - people who haven't died
by this date are censored and assigned a death date of June 1, 2006.

The censor flag is set to null only when death date is same as or EARLIER than
date of diagnosis, i.e. excludes patients diagnosed during autopsy.

*/

When IsEmpty( [Survival Time].CurrentMember.PrevMember )

Then ( Root( [Survival Time] ), [N Total Deaths] )

/*
This is the survival censor count at the top ("root") level of survival time,
*/


Else // At subsequent survival times ( t > 0, censor <> null ), Number at risk is:

(
// Number at risk from previous month,
// minus total number of deaths (both censored and uncensored)
// during current month

( [Survival Time].CurrentMember.PrevMember, [Number at risk] )
- [N Total Deaths]

)

End
);
END SCOPE;

//--

CREATE MEMBER CURRENTCUBE.[MEASURES].[Survival]
AS 100,
FORMAT_STRING = '0.0',
VISIBLE = 1;
SCOPE ([Measures].[Survival]); ([Survival Time].Members(1): Null) =
(
Case

// At the first survival time (defined as Null, i.e. 1st row with "Blank" time):
When IsEmpty( [Survival Time].CurrentMember.PrevMember )

Then (
(
(
( Root([Survival Time]),[N Total Deaths] ) - [N Total Deaths] ) / ( (Root([Survival Time]), [N Total Deaths] ) - ([Survival Time],[N Censored Deaths])
)
)*100
)

Else // At subsequent survival times ( t > 0, censor <> null ):
(
Case

// If everyone's dead (at right end of time(x) axis)
When [Number at risk] = 0

// Then use survival from previous month (PrevMember)
Then "Censored" //( [Survival Time].CurrentMember.PrevMember, [Survival] )

Else (
(
// Number at risk from previous month, minus true failures (noncensored deaths),
// divided by Number at risk from previous month ...
(
( ([Survival Time].CurrentMember.PrevMember, [Number at risk] ) - ( [Survival Time].CurrentMember,[N Noncensored Deaths]) ) /
([Survival Time].CurrentMember.PrevMember, [Number at risk]
)
)
// then multiplied by survival from previous month
* ([Survival Time].CurrentMember.PrevMember, [Survival])
)
)
End
)
End
); END SCOPE;

When I put the Calculated Measure then the survival time dimension in the x axis in the pivot table, it works fine. But when I put a dimension in the filter and choose multiple items (not all and not only one) it tries to build and run the query but seems to hang.

Has anyone else experienced this sort of thing before?

Would it be something to do with the MDX?

I have been struggling with this for a while and not been able to work it out. ANY suggestions would be fantastic.

If you need further information, let me know.

Steve

I have not gone through your code in too much detail, but you main issue is going to be the .CurrentMember function.

When you have mulitple members on the WHERE clause (which is what happens when you filter by more than one member), you do not have a single current member, you actually have a set of current members. SSAS 2005 just does not handle this well. See this blog post for more details: http://sqljunkies.com/WebLog/mosha/archive/2005/11/18/multiselect_friendly_mdx.aspx it might give you some hints on how to alter your code.

|||

Darren,

Thanks for your reply. I tried going to that blog post but couldn't open the page. Are you able to provide another location for the blog?

Cheers,

Stephen

|||

Yeah, I found out that the whole of sqljunkies.com appears to have gone off the air, no word on when or if it will return.

You can find an archived copy of this post in the web archive at http://web.archive.org/web/20070515145719/http://www.sqljunkies.com/WebLog/mosha/archive/2005/11/18/multiselect_friendly_mdx.aspx

|||

Thanks Darren. I found the blog but am not sure how to fix my code.

I actually tried a couple of things with no success. I removed the .CurrentMember from my code (see code snippet) and it worked for single select queries but it still hangs for multiselect.

Code Snippet

/*

The CALCULATE command controls the aggregation of leaf cells in the cube.

If the CALCULATE command is deleted or modified, the data within the cube is affected.

You should edit this command only if you manually specify how the cube is aggregated.

*/

CALCULATE;

//**************************************************************************************

//**************************************************************************************

//**************************************************************************************

// SURVIVAL

// Censor flag = 1 if censored, 0 if noncensored (or true failure),

// NULL if there is data error (death date <= diagnosis date)

CREATE MEMBER CURRENTCUBE.[MEASURES].[N Noncensored Deaths]

AS [Measures].[N Total Deaths] - [Measures].[N Censored Deaths],

FORMAT_STRING = "#",

VISIBLE = 0 ;

CREATE MEMBER CURRENTCUBE.[MEASURES].[Number at risk]

AS 0,

VISIBLE = 1;

SCOPE ([Measures].[Number at risk]); ([Survival Time].Members(1): Null) =

(

Case

/*

At the first survival time (defined as Null, i.e. 1st row with "Blank" time,

when there is no previous month; PrevMember is empty):

Number at risk is simply total number of valid death dates (both censored and uncensored)

in the dataset, which is the total number of patients with censor flag values of

either 0 or 1 (not null), i.e. Number at risk at t == 0 (date of diagnosis).

NOTE: Death dates are right-censored at 01 June 2006 - people who haven't died

by this date are censored and assigned a death date of June 1, 2006.

The censor flag is set to null only when death date is same as or EARLIER than

date of diagnosis, i.e. excludes patients diagnosed during autopsy.

*/

When IsEmpty([Survival Time].PrevMember )

Then ( Root( [Survival Time] ), [N Total Deaths] )

/*

This is the survival censor count at the top ("root") level of survival time,

*/

Else // At subsequent survival times ( t > 0, censor <> null ), Number at risk is:

(

// Number at risk from previous month,

// minus total number of deaths (both censored and uncensored)

// during current month

([Survival Time].PrevMember, [Number at risk] )

- [N Total Deaths]

)

End

);

END SCOPE;

//--

CREATE MEMBER CURRENTCUBE.[MEASURES].[Survival]

AS 100,

FORMAT_STRING = '0.0',

VISIBLE = 1;

SCOPE ([Measures].[Survival]); ([Survival Time].Members(1): Null) =

(

Case

// At the first survival time (defined as Null, i.e. 1st row with "Blank" time):

When IsEmpty([Survival Time].PrevMember )

Then (

(

(

( Root([Survival Time]),[N Total Deaths] ) - [N Total Deaths] ) / ( (Root([Survival Time]), [N Total Deaths] ) - ([Survival Time],[N Censored Deaths])

)

)*100

)

Else // At subsequent survival times ( t > 0, censor <> null ):

(

Case

// If everyone's dead (at right end of time(x) axis)

When [Number at risk] = 0

// Then use survival from previous month (PrevMember)

Then "Censored" //( [Survival Time].CurrentMember.PrevMember, [Survival] )

Else (

(

// Number at risk from previous month, minus true failures (noncensored deaths),

// divided by Number at risk from previous month ...

(

( ([Survival Time].PrevMember, [Number at risk] ) - ([Survival Time],[N Noncensored Deaths]) ) /

([Survival Time].PrevMember, [Number at risk]

)

)

// then multiplied by survival from previous month

* ([Survival Time].PrevMember, [Survival])

)

)

End

)

End

); END SCOPE;

I appreciate you helping me on this.

Cheers,

Steve

|||

Sorry, I was not entirely clear. While removing the explicit CurrentMember calls is good, there is still an implied one for the .PrevMember calls. The query engine still needs a single member context to calculate a PrevMember. There is a way to do this, but it has the unforutnate side effect of slowing down your calc for single member select. What you would need to do is to wrap your case statement (the bit after the equals inside your scope statement) as follows:

GENERATE( EXISTING [Survival Time].Members, <case statement> )

The Existing operator returns the set of one or more survival time members that are in context for the current query and the generate function essentially loops over the set and evaluates the case statement for each one. The results are then aggregated together and returned.

|||

Hi Darren,

My guess is that multi-select is not occurring on the [Survival Time] dimension, otherwise there should have been an error like: "The MDX function CURRENTMEMBER failed because the coordinate for .. attribute contains a set", as mentioned in Mosha's blog. The scenario described by Steve suggests that [Survival Time] is on columns, and some other dimension(s) (which aren't mentioned in the script) are being multi-selected in the filter field - but Steve could confirm this? It might be useful to know the client tool (presumably some flavor of Excel).

|||

Hi Deepak,

You are right. We are selecting dimensions such as age, location etc.

We are using Dundas for our client tool.

Cheers,

Steve

|||

Steve,

Thanks for the clarification - to confirm the exact Dundas product, is it Dundas Chart for .NET - OLAP Services?

|||

Deepak,

It is Dundas Chart for .NET - OLAP Service (5.5).

Thanks,

Steve

|||

Here are some initial ideas for improving script performance - with more information, these could be elaborated:

It might be possible to handle the first [Survival Time] member using static scoping, rather than a run-time case statement, as discussed in this article. What is the structure of [Survival Time] - how many levels does it have?

Not sure which measures are cube vs. calculated, but if [Measures].[N Total Deaths] and [Measures].[N Censored Deaths] are cube measures, [MEASURES].[N Noncensored Deaths] could be implemented as a cube measure as well. Could you describe the fact table/measure group and associated measures?

Using running sum calculations which leverage block computation - it looks like [MEASURES].[Number at risk] could be implemented using a running sum of [N Total Deaths]?

|||

Hi Deepak,

I have run the query when it works and when it hangs. And the following MDX queries are what resulted:

Working:

SELECT NON EMPTY {{[Survival Time].[Survival Time].[All]}, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS, NON EMPTY { Crossjoin({{[Cancer].[Cancers].[All]}, [Cancer].[Cancers].[Stream].members}, VISUALTOTALS({ [Measures].[Survival] }) ) } ON ROWS FROM [Survival] WHERE ( ( [Year of diagnosis].[Year of diagnosis].[All] ), ( [Age at diagnosis].[Age].[All] ), ( [Sex].[Sex].[All] ), ( [Residence].[Residence].[All] ), ( [Rurality].[Rurality].[All] ) )

Not Working (hangs/uses up all resources):

SELECT NON EMPTY {{[Survival Time].[Survival Time].[All]}, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS, NON EMPTY { Crossjoin({{[Cancer].[Cancers].[All]}, [Cancer].[Cancers].[Stream].members}, VISUALTOTALS({ [Measures].[Survival] }) ) } ON ROWS FROM [Survival] WHERE ( VISUALTOTALS({ [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2001], [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2003] }), ( [Age at diagnosis].[Age].[All] ), ( [Sex].[Sex].[All] ), ( [Residence].[Residence].[All] ), ( [Rurality].[Rurality].[All] ) )

Thanks for your help so fay.

Steve

|||

Hi Steve,

Just wanted to clarify a couple of things:

- Is [Survival Time] just a single level (month) dimension - and approx. how many members?

- The VisualTotals() seem to be superfluous, so could you check whether the 2nd query still hangs without VisualTotals(), like:

SELECT NON EMPTY {{[Survival Time].[Survival Time].[All]}, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS, NON EMPTY { Crossjoin({{[Cancer].[Cancers].[All]}, [Cancer].[Cancers].[Stream].members}, { [Measures].[Survival] } ) } ON ROWS FROM [Survival] WHERE ( { [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2001], [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2003] }, ( [Age at diagnosis].[Age].[All] ), ( [Sex].[Sex].[All] ), ( [Residence].[Residence].[All] ), ( [Rurality].[Rurality].[All] ) )

|||

Hi Deepak,

The [Survival Time] dimension is a single level dimension. It is a count of months from a starting date to a death date.

I also ran the query from the browser in SQL Server Management Studio which dropped Visual Totals and it still hung.

Thanks again for your help.

Cheers,

Steve

|||

I'm not sure you need any of the VisualTotals functions. And unless you have overriden the default member settings on some of your dimensions, explicit referencing the default members would be redundant. The following two queries should be equivalent to the last 2 that you posted.

SELECT

NON EMPTY

{

{[Survival Time].[Survival Time].[All]}

, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS

, NON EMPTY

{[Cancer].[Cancers].[All]

, [Cancer].[Cancers].[Stream].members}

ON ROWS

FROM [Survival]

WHERE

( [Measures].[Survival],[Year of diagnosis].[Year of diagnosis].[All] );

--Was not Working

SELECT

NON EMPTY

{

{[Survival Time].[Survival Time].[All]}

, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS

, NON EMPTY

{[Cancer].[Cancers].[All]

, [Cancer].[Cancers].[Stream].members}

ON ROWS

FROM [Survival]

WHERE ( [Measures].[Survival],

{ [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2001]

, [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2003] })

AS hangs when running a complex mdx querie

Hi all,

I am having a problem with Analysis Services. Currently we are developing an analysis application that enables a user to view up to 5 year survival for patients.

I have written the following MDX to perform the calculated measure:

Code Snippet

/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;


//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
// SURVIVAL


// Censor flag = 1 if censored, 0 if noncensored (or true failure),
// NULL if there is data error (death date <= diagnosis date)


CREATE MEMBER CURRENTCUBE.[MEASURES].[N Noncensored Deaths]
AS [Measures].[N Total Deaths] - [Measures].[N Censored Deaths],
FORMAT_STRING = "#",
VISIBLE = 0 ;


CREATE MEMBER CURRENTCUBE.[MEASURES].[Number at risk]
AS 0,
VISIBLE = 1;
SCOPE ([Measures].[Number at risk]); ([Survival Time].Members(1): Null) =
(
Case

/*

At the first survival time (defined as Null, i.e. 1st row with "Blank" time,
when there is no previous month; PrevMember is empty):

Number at risk is simply total number of valid death dates (both censored and uncensored)
in the dataset, which is the total number of patients with censor flag values of
either 0 or 1 (not null), i.e. Number at risk at t == 0 (date of diagnosis).

NOTE: Death dates are right-censored at 01 June 2006 - people who haven't died
by this date are censored and assigned a death date of June 1, 2006.

The censor flag is set to null only when death date is same as or EARLIER than
date of diagnosis, i.e. excludes patients diagnosed during autopsy.

*/

When IsEmpty( [Survival Time].CurrentMember.PrevMember )

Then ( Root( [Survival Time] ), [N Total Deaths] )

/*
This is the survival censor count at the top ("root") level of survival time,
*/


Else // At subsequent survival times ( t > 0, censor <> null ), Number at risk is:

(
// Number at risk from previous month,
// minus total number of deaths (both censored and uncensored)
// during current month

( [Survival Time].CurrentMember.PrevMember, [Number at risk] )
- [N Total Deaths]

)

End
);
END SCOPE;

//--

CREATE MEMBER CURRENTCUBE.[MEASURES].[Survival]
AS 100,
FORMAT_STRING = '0.0',
VISIBLE = 1;
SCOPE ([Measures].[Survival]); ([Survival Time].Members(1): Null) =
(
Case

// At the first survival time (defined as Null, i.e. 1st row with "Blank" time):
When IsEmpty( [Survival Time].CurrentMember.PrevMember )

Then (
(
(
( Root([Survival Time]),[N Total Deaths] ) - [N Total Deaths] ) / ( (Root([Survival Time]), [N Total Deaths] ) - ([Survival Time],[N Censored Deaths])
)
)*100
)

Else // At subsequent survival times ( t > 0, censor <> null ):
(
Case

// If everyone's dead (at right end of time(x) axis)
When [Number at risk] = 0

// Then use survival from previous month (PrevMember)
Then "Censored" //( [Survival Time].CurrentMember.PrevMember, [Survival] )

Else (
(
// Number at risk from previous month, minus true failures (noncensored deaths),
// divided by Number at risk from previous month ...
(
( ([Survival Time].CurrentMember.PrevMember, [Number at risk] ) - ( [Survival Time].CurrentMember,[N Noncensored Deaths]) ) /
([Survival Time].CurrentMember.PrevMember, [Number at risk]
)
)
// then multiplied by survival from previous month
* ([Survival Time].CurrentMember.PrevMember, [Survival])
)
)
End
)
End
); END SCOPE;

When I put the Calculated Measure then the survival time dimension in the x axis in the pivot table, it works fine. But when I put a dimension in the filter and choose multiple items (not all and not only one) it tries to build and run the query but seems to hang.

Has anyone else experienced this sort of thing before?

Would it be something to do with the MDX?

I have been struggling with this for a while and not been able to work it out. ANY suggestions would be fantastic.

If you need further information, let me know.

Steve

I have not gone through your code in too much detail, but you main issue is going to be the .CurrentMember function.

When you have mulitple members on the WHERE clause (which is what happens when you filter by more than one member), you do not have a single current member, you actually have a set of current members. SSAS 2005 just does not handle this well. See this blog post for more details: http://sqljunkies.com/WebLog/mosha/archive/2005/11/18/multiselect_friendly_mdx.aspx it might give you some hints on how to alter your code.

|||

Darren,

Thanks for your reply. I tried going to that blog post but couldn't open the page. Are you able to provide another location for the blog?

Cheers,

Stephen

|||

Yeah, I found out that the whole of sqljunkies.com appears to have gone off the air, no word on when or if it will return.

You can find an archived copy of this post in the web archive at http://web.archive.org/web/20070515145719/http://www.sqljunkies.com/WebLog/mosha/archive/2005/11/18/multiselect_friendly_mdx.aspx

|||

Thanks Darren. I found the blog but am not sure how to fix my code.

I actually tried a couple of things with no success. I removed the .CurrentMember from my code (see code snippet) and it worked for single select queries but it still hangs for multiselect.

Code Snippet

/*

The CALCULATE command controls the aggregation of leaf cells in the cube.

If the CALCULATE command is deleted or modified, the data within the cube is affected.

You should edit this command only if you manually specify how the cube is aggregated.

*/

CALCULATE;

//**************************************************************************************

//**************************************************************************************

//**************************************************************************************

// SURVIVAL

// Censor flag = 1 if censored, 0 if noncensored (or true failure),

// NULL if there is data error (death date <= diagnosis date)

CREATE MEMBER CURRENTCUBE.[MEASURES].[N Noncensored Deaths]

AS [Measures].[N Total Deaths] - [Measures].[N Censored Deaths],

FORMAT_STRING = "#",

VISIBLE = 0 ;

CREATE MEMBER CURRENTCUBE.[MEASURES].[Number at risk]

AS 0,

VISIBLE = 1;

SCOPE ([Measures].[Number at risk]); ([Survival Time].Members(1): Null) =

(

Case

/*

At the first survival time (defined as Null, i.e. 1st row with "Blank" time,

when there is no previous month; PrevMember is empty):

Number at risk is simply total number of valid death dates (both censored and uncensored)

in the dataset, which is the total number of patients with censor flag values of

either 0 or 1 (not null), i.e. Number at risk at t == 0 (date of diagnosis).

NOTE: Death dates are right-censored at 01 June 2006 - people who haven't died

by this date are censored and assigned a death date of June 1, 2006.

The censor flag is set to null only when death date is same as or EARLIER than

date of diagnosis, i.e. excludes patients diagnosed during autopsy.

*/

When IsEmpty([Survival Time].PrevMember )

Then ( Root( [Survival Time] ), [N Total Deaths] )

/*

This is the survival censor count at the top ("root") level of survival time,

*/

Else // At subsequent survival times ( t > 0, censor <> null ), Number at risk is:

(

// Number at risk from previous month,

// minus total number of deaths (both censored and uncensored)

// during current month

([Survival Time].PrevMember, [Number at risk] )

- [N Total Deaths]

)

End

);

END SCOPE;

//--

CREATE MEMBER CURRENTCUBE.[MEASURES].[Survival]

AS 100,

FORMAT_STRING = '0.0',

VISIBLE = 1;

SCOPE ([Measures].[Survival]); ([Survival Time].Members(1): Null) =

(

Case

// At the first survival time (defined as Null, i.e. 1st row with "Blank" time):

When IsEmpty([Survival Time].PrevMember )

Then (

(

(

( Root([Survival Time]),[N Total Deaths] ) - [N Total Deaths] ) / ( (Root([Survival Time]), [N Total Deaths] ) - ([Survival Time],[N Censored Deaths])

)

)*100

)

Else // At subsequent survival times ( t > 0, censor <> null ):

(

Case

// If everyone's dead (at right end of time(x) axis)

When [Number at risk] = 0

// Then use survival from previous month (PrevMember)

Then "Censored" //( [Survival Time].CurrentMember.PrevMember, [Survival] )

Else (

(

// Number at risk from previous month, minus true failures (noncensored deaths),

// divided by Number at risk from previous month ...

(

( ([Survival Time].PrevMember, [Number at risk] ) - ([Survival Time],[N Noncensored Deaths]) ) /

([Survival Time].PrevMember, [Number at risk]

)

)

// then multiplied by survival from previous month

* ([Survival Time].PrevMember, [Survival])

)

)

End

)

End

); END SCOPE;

I appreciate you helping me on this.

Cheers,

Steve

|||

Sorry, I was not entirely clear. While removing the explicit CurrentMember calls is good, there is still an implied one for the .PrevMember calls. The query engine still needs a single member context to calculate a PrevMember. There is a way to do this, but it has the unforutnate side effect of slowing down your calc for single member select. What you would need to do is to wrap your case statement (the bit after the equals inside your scope statement) as follows:

GENERATE( EXISTING [Survival Time].Members, <case statement> )

The Existing operator returns the set of one or more survival time members that are in context for the current query and the generate function essentially loops over the set and evaluates the case statement for each one. The results are then aggregated together and returned.

|||

Hi Darren,

My guess is that multi-select is not occurring on the [Survival Time] dimension, otherwise there should have been an error like: "The MDX function CURRENTMEMBER failed because the coordinate for .. attribute contains a set", as mentioned in Mosha's blog. The scenario described by Steve suggests that [Survival Time] is on columns, and some other dimension(s) (which aren't mentioned in the script) are being multi-selected in the filter field - but Steve could confirm this? It might be useful to know the client tool (presumably some flavor of Excel).

|||

Hi Deepak,

You are right. We are selecting dimensions such as age, location etc.

We are using Dundas for our client tool.

Cheers,

Steve

|||

Steve,

Thanks for the clarification - to confirm the exact Dundas product, is it Dundas Chart for .NET - OLAP Services?

|||

Deepak,

It is Dundas Chart for .NET - OLAP Service (5.5).

Thanks,

Steve

|||

Here are some initial ideas for improving script performance - with more information, these could be elaborated:

It might be possible to handle the first [Survival Time] member using static scoping, rather than a run-time case statement, as discussed in this article. What is the structure of [Survival Time] - how many levels does it have?

Not sure which measures are cube vs. calculated, but if [Measures].[N Total Deaths] and [Measures].[N Censored Deaths] are cube measures, [MEASURES].[N Noncensored Deaths] could be implemented as a cube measure as well. Could you describe the fact table/measure group and associated measures?

Using running sum calculations which leverage block computation - it looks like [MEASURES].[Number at risk] could be implemented using a running sum of [N Total Deaths]?

|||

Hi Deepak,

I have run the query when it works and when it hangs. And the following MDX queries are what resulted:

Working:

SELECT NON EMPTY {{[Survival Time].[Survival Time].[All]}, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS, NON EMPTY { Crossjoin({{[Cancer].[Cancers].[All]}, [Cancer].[Cancers].[Stream].members}, VISUALTOTALS({ [Measures].[Survival] }) ) } ON ROWS FROM [Survival] WHERE ( ( [Year of diagnosis].[Year of diagnosis].[All] ), ( [Age at diagnosis].[Age].[All] ), ( [Sex].[Sex].[All] ), ( [Residence].[Residence].[All] ), ( [Rurality].[Rurality].[All] ) )

Not Working (hangs/uses up all resources):

SELECT NON EMPTY {{[Survival Time].[Survival Time].[All]}, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS, NON EMPTY { Crossjoin({{[Cancer].[Cancers].[All]}, [Cancer].[Cancers].[Stream].members}, VISUALTOTALS({ [Measures].[Survival] }) ) } ON ROWS FROM [Survival] WHERE ( VISUALTOTALS({ [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2001], [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2003] }), ( [Age at diagnosis].[Age].[All] ), ( [Sex].[Sex].[All] ), ( [Residence].[Residence].[All] ), ( [Rurality].[Rurality].[All] ) )

Thanks for your help so fay.

Steve

|||

Hi Steve,

Just wanted to clarify a couple of things:

- Is [Survival Time] just a single level (month) dimension - and approx. how many members?

- The VisualTotals() seem to be superfluous, so could you check whether the 2nd query still hangs without VisualTotals(), like:

SELECT NON EMPTY {{[Survival Time].[Survival Time].[All]}, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS, NON EMPTY { Crossjoin({{[Cancer].[Cancers].[All]}, [Cancer].[Cancers].[Stream].members}, { [Measures].[Survival] } ) } ON ROWS FROM [Survival] WHERE ( { [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2001], [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2003] }, ( [Age at diagnosis].[Age].[All] ), ( [Sex].[Sex].[All] ), ( [Residence].[Residence].[All] ), ( [Rurality].[Rurality].[All] ) )

|||

Hi Deepak,

The [Survival Time] dimension is a single level dimension. It is a count of months from a starting date to a death date.

I also ran the query from the browser in SQL Server Management Studio which dropped Visual Totals and it still hung.

Thanks again for your help.

Cheers,

Steve

|||

I'm not sure you need any of the VisualTotals functions. And unless you have overriden the default member settings on some of your dimensions, explicit referencing the default members would be redundant. The following two queries should be equivalent to the last 2 that you posted.

SELECT

NON EMPTY

{

{[Survival Time].[Survival Time].[All]}

, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS

, NON EMPTY

{[Cancer].[Cancers].[All]

, [Cancer].[Cancers].[Stream].members}

ON ROWS

FROM [Survival]

WHERE

( [Measures].[Survival],[Year of diagnosis].[Year of diagnosis].[All] );

--Was not Working

SELECT

NON EMPTY

{

{[Survival Time].[Survival Time].[All]}

, [Survival Time].[Survival Time].[Survival Time].members} ON COLUMNS

, NON EMPTY

{[Cancer].[Cancers].[All]

, [Cancer].[Cancers].[Stream].members}

ON ROWS

FROM [Survival]

WHERE ( [Measures].[Survival],

{ [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2001]

, [Year of diagnosis].[Year of diagnosis].[Year of diagnosis].&[2003] })