Showing posts with label access. Show all posts
Showing posts with label access. Show all posts

Sunday, March 25, 2012

Cursor Help Please

I have a requirement for a user to access time sheet information by accessing a SharePoint portal listing. They will be required enter a date range. The login will be based on their domain access.

Based on the query below, I can return a result set which gives the user all rows they'll need, grouped accordingly and based on a date range. Except for a required billable percentage figure. A billable percentage is defined as billable hours / total hours * 100 or based on the query below;

day1 through 7_hr1 [Worked_hrs] where the project <> admin (@.Worked_hrs_B), divided by the total [Worked_hrs](@.Total_Worked_hrs).

I'm pretty sure I need to use a cursor which will tally all the @.Worked_hrs_NB rows, and another cursor which will tally @.Total_Worked_hrs rows and then divide the two variables * 100, to return it in the @.Billable variable.

This is where I get lost. I'm ashamed to say that my TSQL is rusty & weak at best. Rather than confuse anyone with my idea of cursor syntax, I left it out of this query, & just included the variables I assumed would fit.

A down'n'dirty cursor lesson would be most appreciated (If that's what this needs). Thanks in advance for your help.

DECLARE
@.pe_date1 AS SMALLDATETIME, --Prompt
@.pe_date2 AS SMALLDATETIME, --Prompt
@.emp_id AS CHAR (30), --Login
@.Worked_hrs_B AS INT,
@.Total_Worked_hrs AS INT,
@.Precent AS INT
SET @.pe_date1 = '6/01/2004'
SET @.pe_date2 = '7/01/2005'
SET @.emp_id = 'degajx'
************************************************************************
SET @.Worked_hrs_B = '' Here's where I get lost
SET @.Total_Worked_hrs = '' with the variables & the
SET @.Precent = '' --Make Header Info cursor to populate them.
************************************************************************
SELECT
pjlabhdr.docnbr
, pjlabhdr.pe_date
, pjlabdet.project
, pjlabdet.pjt_entity
, pjlabdet.ld_desc
, (
pjlabdet.day1_hr1 +
pjlabdet.day2_hr1 +
pjlabdet.day3_hr1 +
pjlabdet.day4_hr1 +
pjlabdet.day5_hr1 +
pjlabdet.day6_hr1 +
pjlabdet.day7_hr1
) AS [Worked_hrs]
, pjemploy.manager1
, ltle.employeename AS [Manager] --Make Header Info
, SubAcct.Descr --Make Header Info ************************************************************************
, @.Percent AS [Billable %] --An accurate return, though repeating would be fine.
************************************************************************
FROM IEM_Cut.dbo.PJLABHDR pjlabhdr
INNER JOIN
IEM_Cut.dbo.PJEMPLOY
ON pjlabhdr.employee = pjemploy.employee
Inner JOIN
labortool..laboremployee ltle (NOLOCK)
ON ltle.empid = pjemploy.manager1
LEFT OUTER JOIN
IEM_Cut.dbo.PJLABDET pjlabdet
ON pjlabhdr.docnbr = pjlabdet.docnbr
LEFT OUTER JOIN
IEM_Cut.dbo.SubAcct SubAcct
ON pjemploy.gl_subacct = SubAcct.Sub
WHERE
( pjlabdet.day1_hr1 <> 0
OR pjlabdet.day2_hr1 <> 0
OR pjlabdet.day3_hr1 <> 0
OR pjlabdet.day4_hr1 <> 0
OR pjlabdet.day5_hr1 <> 0
OR pjlabdet.day6_hr1 <> 0
OR pjlabdet.day7_hr1 <> 0
)
AND pjlabhdr.CpnyID_home = 'IEM'
AND pjlabhdr.pe_date BETWEEN CONVERT (varchar, @.pe_date1 , 107) AND CONVERT (varchar, @.pe_date2 , 107)
AND pjlabhdr.employee = @.emp_id
ORDER BY
pjlabhdr.pe_date ASC --Group
, pjlabhdr.docnbr ASC --Group
, pjlabdet.project ASC --Group
, pjlabdet.pjt_entity ASC --Group

You don't really need a cursor. You can write two queries that performs the required SUM operations and divide the results. For example:

select (select sum(...) from ....)/((select sum(...) from ...)*100.0) as billable_per

See Books Online for more details on how to write scalar queries, group by, expressions etc.

sql

Thursday, March 22, 2012

CurrentProject.IsConnected is reporting on what?

Does CurrentProject.IsConnected tell me that the ADP is connected to the SQL
database, or that it sees the network?
I have an ACCESS ADP connecting to a SQL db via a wireless network. I
thought I would check CurrentProject.IsConnected to see if I had lost
connection due to out of wireless range, and if so, re connect to the DB via
code. But when I come back into range, this CurrentProject.IsConnected is
always true, but I am still not re-connected to the DB.
Any thoughts?
Thanks,
SteveTry posting to one of the Access newsgroups instead - try:
microsoft.public.access.adp.sqlserver
-Sue
On Tue, 11 Apr 2006 07:49:02 -0700, SteveInBeloit
<SteveInBeloit@.discussions.microsoft.com> wrote:

>Does CurrentProject.IsConnected tell me that the ADP is connected to the SQ
L
>database, or that it sees the network?
>I have an ACCESS ADP connecting to a SQL db via a wireless network. I
>thought I would check CurrentProject.IsConnected to see if I had lost
>connection due to out of wireless range, and if so, re connect to the DB vi
a
>code. But when I come back into range, this CurrentProject.IsConnected is
>always true, but I am still not re-connected to the DB.
>Any thoughts?
>Thanks,
>Steve

Current Year

Hi,
I am new at T-SQL.
I need to access a table with the field inv_dt.
I need the sum of the invoices where it takes only the sum of the current
year invoices.
When 2006 arrives I only want the sum of 2006 invoices without having to
rewrite the code for each year that rolls around.
Any help would be appreciated.
Thanks,
TerryHi, Terry
Try something like this:
SELECT SUM(ammount) FROM invoices
WHERE YEAR(inv_dt)=YEAR(GETDATE())
Razvan|||SELECT SUM(Col)
FROM YourTable
WHERE
inv_dt >= DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)
AND inv_dt < DATEADD(yy, DATEDIFF(yy, 0, GETDATE())+1, 0)
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"newbi" <twillett@.cox-internet.com> wrote in message
news:Vapgf.24167$4l5.6904@.dukeread05...
> Hi,
> I am new at T-SQL.
> I need to access a table with the field inv_dt.
> I need the sum of the invoices where it takes only the sum of the current
> year invoices.
> When 2006 arrives I only want the sum of 2006 invoices without having to
> rewrite the code for each year that rolls around.
> Any help would be appreciated.
> Thanks,
> Terry
>|||DECLARE
@.firstOfThisYear SMALLDATETIME,
@.firstOfNextYear SMALLDATETIME
SET @.firstOfThisYear = CONVERT(CHAR(4), YEAR(CURRENT_TIMESTAMP))+'0101'
SET @.firstOfNextYear = DATEADD(YEAR,1,@.FirstOfThisYear)
SELECT SUM(amount)
FROM invoices
WHERE inv_dt >= @.firstOfThisYear
AND inv_dt < @.firstOfNextYear
Now if inv_dt has an index, you can use it.
"newbi" <twillett@.cox-internet.com> wrote in message
news:Vapgf.24167$4l5.6904@.dukeread05...
> Hi,
> I am new at T-SQL.
> I need to access a table with the field inv_dt.
> I need the sum of the invoices where it takes only the sum of the current
> year invoices.
> When 2006 arrives I only want the sum of 2006 invoices without having to
> rewrite the code for each year that rolls around.
> Any help would be appreciated.
> Thanks,
> Terry
>|||Careful with that one, Razvan -- since you're using a function on the column
the query can't be satisfied using an index s.
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Razvan Socol" <rsocol@.gmail.com> wrote in message
news:1132601271.210016.241970@.g44g2000cwa.googlegroups.com...
> Hi, Terry
> Try something like this:
> SELECT SUM(ammount) FROM invoices
> WHERE YEAR(inv_dt)=YEAR(GETDATE())
> Razvan
>|||Thanks Guys,
That worked perfectly.
Terry
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:eRtAxHt7FHA.2176@.TK2MSFTNGP14.phx.gbl...
> SELECT SUM(Col)
> FROM YourTable
> WHERE
> inv_dt >= DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)
> AND inv_dt < DATEADD(yy, DATEDIFF(yy, 0, GETDATE())+1, 0)
> --
> Adam Machanic
> Pro SQL Server 2005, available now
> http://www.apress.com/book/bookDisplay.html?bID=457
> --
>
> "newbi" <twillett@.cox-internet.com> wrote in message
> news:Vapgf.24167$4l5.6904@.dukeread05...
>|||> Careful with that one, Razvan -- since you're using a function on the columnd">
> the query can't be satisfied using an index s.
Yes, indeed. But probably, we won't have more than 5-10 years of data
in the table, so an index scan would be used anyway. Anyway, you are
correct that your query is preferable, because the optimizer has more
options available.
Razvan

Wednesday, March 7, 2012

Cube Roles - How to restrict access to certain members

I have a dimension called Account that has five levels. I'm trying to define a cube role to deny access to accounts in the lowest level that starts with the letters GL. I tried applying a filter in the dimension data tab in the role designer, however, this only seems to create a static rule. The account structure gets updated all the time and I want to restrict access to all accounts that start with the letters GL now and in the future.

When I created a rule in another dimension using a top-level static member, a denied member set was created in the advanced tab. I think I need to create something similar for the Account dimension, but I just can't get the syntax of MDX. I tried the BOL samples but can't find anything since I want to filter only part of the member name.

Try typing something like the following expression for DeniedSet:

Filter(Account.Levels(4), Account.Name >= 'GL' AND Account.Name < 'GM')

|||

Thanks, but that didn't work. In addition, I tried Filter([Account].Members, Left([Account].CurrentMember.Name, 2) = "GL") but that didn't work either. I'm wondering if there are too many members to filter at the bottom level.

Oddly, I was able to solve part of the problem by Enabling Visual Total in my other dimensions. I can filter GL type accounts in my other dimensions because there is only one fixed GL member in those dimensions. Since GL accounts only match up to the GL members in the other dimensions and since those GL members have been filtered, GL Accounts are not displayed in the cube result.

I will still try to find a solution, although I can restrict GL data from being displayed in the cube, the GL accounts still show up in the drop down. It's a good thing that when the user selects GL accounts, nothing is displayed.

Saturday, February 25, 2012

Cube meta data on a web page

How do I access AS database meta data (cubes + properties) from an
asp.net page?
Hans
There are several approaches you could use.
If you are looking for documentation, then nightly you could run the OLAP
Scribe utility (which generates a .doc file) -- and the link to the .doc
file from your asp.net application. That will give you pretty extensive
documentation.
http://www.microsoft.com/downloads/d...DisplayLang=en
If all you want is populate a list, then your asp.net application can use
OLAP Schema Rowsets, see Books On line for information on the topic.
As a third approach, if you know the database you want to connect to, then
you could use the Catalog object which is exposed via ADOMD.NET (see the
ADOMD.NET documentation on how to do that).
http://www.microsoft.com/downloads/d...DisplayLang=en
Hope that helps.
Dave Wickert [MSFT]
dwickert@.online.microsoft.com
Program Manager
BI SystemsTeam
SQL BI Product Unit (Analysis Services)
This posting is provided "AS IS" with no warranties, and confers no rights.
"hansiman" <han@.sen.se> wrote in message
news:eq7au0hopksiglbe7s893v1uu3a3n1f5ui@.4ax.com...
> How do I access AS database meta data (cubes + properties) from an
> asp.net page?
> Hans

Cube meta data on a web page

How do I access AS database meta data (cubes + properties) from an
asp.net page?
HansThere are several approaches you could use.
If you are looking for documentation, then nightly you could run the OLAP
Scribe utility (which generates a .doc file) -- and the link to the .doc
file from your asp.net application. That will give you pretty extensive
documentation.
http://www.microsoft.com/downloads/...&DisplayLang=en
If all you want is populate a list, then your asp.net application can use
OLAP Schema Rowsets, see Books On line for information on the topic.
As a third approach, if you know the database you want to connect to, then
you could use the Catalog object which is exposed via ADOMD.NET (see the
ADOMD.NET documentation on how to do that).
http://www.microsoft.com/downloads/...&DisplayLang=en
Hope that helps.
--
Dave Wickert [MSFT]
dwickert@.online.microsoft.com
Program Manager
BI SystemsTeam
SQL BI Product Unit (Analysis Services)
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"hansiman" <han@.sen.se> wrote in message
news:eq7au0hopksiglbe7s893v1uu3a3n1f5ui@.
4ax.com...
> How do I access AS database meta data (cubes + properties) from an
> asp.net page?
> Hans

Cube design e best client tool to access olap database

Hi all,

My doubt is about the best client tool to use for access cube olap. Currently i use excel for some tests but when expand until third ou fourth level the query delays a time not acceptable many times hanging the virtual server.

Another doubt is about cube design the bahavor described above is normal?

Is my server i have a fact table with 211.000 rows, 17 columns (with two calculations columns) and 15 dimension tables ( I think tha is a small database). This tables are organized in a starschema inside a SQL Server 2005 database. The cube 15 dimensions (one with two hierarquies) and with five partitions based in the hierarquies.

Virtual Server Configuration:

512MB Physical Memory.

CPU Intel Core Centrino 1.66GHz

Windows 2003 SP1

SQLServer 2005 SP2

Apologies about my english.

Thanks

Hi!

It is a little bit hard to tell without knowing more about your cube. Have you designed proper attribute relationsships and aggregations? You can download the performance guide for AS2005 pointed to a the top of this group.

Next, I think that a cube of that size and that many dimensions will require more memory than 512 MB. I also run AS2005 on my laptop but not as a virtual server(because it is slower) and I have 2 GB of physical memory.

The problem in Excel might be related to the physical limits of you machine. To do a real test of Excels limits you should run it from a workstation without any server software installed. In that case 512 MB can be enough even if most workstations today have at least 1 GB RAM installed.

HTH

Thomas Ivarsson

Tuesday, February 14, 2012

Crytarl Report with Dabase access

dear all ,

i use crystal report from dot net 2003 (i use dotnet version architect).
with database access.

and i have problem to set parameter for query access in crystal report.

if i use database mssqlserver 2000 in crystal report i just select store procedure and the parameter for store precedure will otomatically add in crystal report.

sampel query store procedure like this

select * from tblcustomer
where CustName = @.custName

the parameter @.CustName otomatically add in crystal report.

how to implament that if i use database access.
so i can send a value for @.Custname from my applicationAs i have worked for VB.net so i'll how i used to send parameter value externally
first u need to define
Dim pv As New CrystalDecisions.Shared.ParameterValues
Dim pdv As New CrystalDecisions.Shared.ParameterDiscreteValue

pdv.Value = EntityCode
pv.Add(pdvScriptCode1)

RptViewer.DataDefinition.ParameterFields("@.Customer").ApplyCurrentValues(pv)

thats it...
Try it out n tell me the result whther its working......