Monday, March 19, 2012
Calling a UDF that returns a table from within a select statement
two input parameters. Can I call the UDF within a Select statement?
i.e.
SELECT dbo.GetTable(col2,1)
FROM table
"Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
>I have a UDF that returns a table data type by recursion. The UDF takes a
> two input parameters. Can I call the UDF within a Select statement?
> i.e.
> SELECT dbo.GetTable(col2,1)
> FROM table
If you are passing a column value into the UDF you must use the new (SQL
2005) APPLY operator
SELECT t.whatever, gt.*
FROM table t
CROSS APPLY dbo.GetTable(col2,1) gt
David
|||David,
Does this apply only to CLR functions?
-- Bill
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:eG9QJ7JTHHA.3428@.TK2MSFTNGP04.phx.gbl...
>
> "Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
> news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
> If you are passing a column value into the UDF you must use the new (SQL
> 2005) APPLY operator
> SELECT t.whatever, gt.*
> FROM table t
> CROSS APPLY dbo.GetTable(col2,1) gt
> David
>
|||Thanks,
So, is there a method or workaround for doing this in SQL Server 2000?
"David Browne" wrote:
>
> "Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
> news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
> If you are passing a column value into the UDF you must use the new (SQL
> 2005) APPLY operator
> SELECT t.whatever, gt.*
> FROM table t
> CROSS APPLY dbo.GetTable(col2,1) gt
> David
>
>
|||"Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
news:C5C4903C-A9CA-4C80-8B8D-85E0C7C9A4AD@.microsoft.com...
> Thanks,
> So, is there a method or workaround for doing this in SQL Server 2000?
>
Not in the general case (thus the need to extend SQL). But if you have only
a few values for col2, you can perhaps use a cursor and a temp table to
construct the results.
David
|||"AlterEgo" <alterego55@.dslextreme.com> wrote in message
news:e7iqBLKTHHA.4756@.TK2MSFTNGP06.phx.gbl...
> David,
> Does this apply only to CLR functions?
>
No. All Table-Valued UDF's/.
David
Calling a UDF that returns a table from within a select statement
two input parameters. Can I call the UDF within a Select statement?
i.e.
SELECT dbo.GetTable(col2,1)
FROM table"Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
>I have a UDF that returns a table data type by recursion. The UDF takes a
> two input parameters. Can I call the UDF within a Select statement?
> i.e.
> SELECT dbo.GetTable(col2,1)
> FROM table
If you are passing a column value into the UDF you must use the new (SQL
2005) APPLY operator
SELECT t.whatever, gt.*
FROM table t
CROSS APPLY dbo.GetTable(col2,1) gt
David|||David,
Does this apply only to CLR functions?
-- Bill
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:eG9QJ7JTHHA.3428@.TK2MSFTNGP04.phx.gbl...
>
> "Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
> news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
>>I have a UDF that returns a table data type by recursion. The UDF takes a
>> two input parameters. Can I call the UDF within a Select statement?
>> i.e.
>> SELECT dbo.GetTable(col2,1)
>> FROM table
> If you are passing a column value into the UDF you must use the new (SQL
> 2005) APPLY operator
> SELECT t.whatever, gt.*
> FROM table t
> CROSS APPLY dbo.GetTable(col2,1) gt
> David
>|||Thanks,
So, is there a method or workaround for doing this in SQL Server 2000?
"David Browne" wrote:
>
> "Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
> news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
> >I have a UDF that returns a table data type by recursion. The UDF takes a
> > two input parameters. Can I call the UDF within a Select statement?
> >
> > i.e.
> >
> > SELECT dbo.GetTable(col2,1)
> > FROM table
> If you are passing a column value into the UDF you must use the new (SQL
> 2005) APPLY operator
> SELECT t.whatever, gt.*
> FROM table t
> CROSS APPLY dbo.GetTable(col2,1) gt
> David
>
>|||"Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
news:C5C4903C-A9CA-4C80-8B8D-85E0C7C9A4AD@.microsoft.com...
> Thanks,
> So, is there a method or workaround for doing this in SQL Server 2000?
>
Not in the general case (thus the need to extend SQL). But if you have only
a few values for col2, you can perhaps use a cursor and a temp table to
construct the results.
David|||"AlterEgo" <alterego55@.dslextreme.com> wrote in message
news:e7iqBLKTHHA.4756@.TK2MSFTNGP06.phx.gbl...
> David,
> Does this apply only to CLR functions?
>
No. All Table-Valued UDF's/.
David
Calling a UDF that returns a table from within a select statement
two input parameters. Can I call the UDF within a Select statement?
i.e.
SELECT dbo.GetTable(col2,1)
FROM table"Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
>I have a UDF that returns a table data type by recursion. The UDF takes a
> two input parameters. Can I call the UDF within a Select statement?
> i.e.
> SELECT dbo.GetTable(col2,1)
> FROM table
If you are passing a column value into the UDF you must use the new (SQL
2005) APPLY operator
SELECT t.whatever, gt.*
FROM table t
CROSS APPLY dbo.GetTable(col2,1) gt
David|||David,
Does this apply only to CLR functions?
-- Bill
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:eG9QJ7JTHHA.3428@.TK2MSFTNGP04.phx.gbl...
>
> "Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
> news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
> If you are passing a column value into the UDF you must use the new (SQL
> 2005) APPLY operator
> SELECT t.whatever, gt.*
> FROM table t
> CROSS APPLY dbo.GetTable(col2,1) gt
> David
>|||"AlterEgo" <alterego55@.dslextreme.com> wrote in message
news:e7iqBLKTHHA.4756@.TK2MSFTNGP06.phx.gbl...
> David,
> Does this apply only to CLR functions?
>
No. All Table-Valued UDF's/.
David
Friday, February 24, 2012
calendar format
I have a problem with the calendar.
I have a parameter from datetime type.
But I want to change this calendar's format.
When I click the calendar button near the parameter textbox and select a date like 14.3.2001, 3.14.2001 is written to the textbox. And this causes to an error.(Because 14 can't be a month number)
How can I change that parameter's format or calendar's format?
Any idea about this?The date supplied to the calendar is based on the accept language for the browser. In IE look at Tools->Internet Options->Languages and make sure the top language is what you expect.|||
Daniel Reib wrote:
The date supplied to the calendar is based on the accept language for the browser. In IE look at Tools->Internet Options->Languages and make sure the top language is what you expect.
Thanks I did what you said but it didn't work.
Because I am not working on IE now .
I am working on Reporting Services side on .NET.
I changed regional settings from control panel too but nothing different happened.
I couldn't see the calendar's properties.
What can I do else?
Sunday, February 19, 2012
Calculation problems
Im having a strange problem. Im trying to calculate a percent and store it in the database. The column type is float. Here is my code:
Insert into QuoteLineData
(GM) values ((::price::-::opcost::)/::price::))
Where the price and opcost are parameters in a WEB page.
No mater what I do, it will calculate to 0 or 1, rounding the number up or down.
How can I keep the precision to get a fraction in the float field?
ThanksYour sample code is missing a parenthesis after price-cost, it's probably a typo, but could generate some strange results.
Try inserting 12.34 into the table to make sure the column will accept decimal points.
If that works, try displaying the results of the calculation to make sure decimals are being generated.
If both of those work, try calculating into an intermediate variable and then inserting the intermediate variable into the table.
Good Luck,|||OK,
This is very weird.
The values are coming from MS Front-page.
If I enter an integer for the values the result will be 0 or 1 it will round up or down.
However, if I enter a . After any one of the integers, the calculation is correct and it will give the value with a 6 decimal point precision.
Any ideas what is happening and how I can bypass this problem?
Thanks|||SQL Server has a way of converting results to the lowest common denominator, in this case an int. by adding a "." you have converted the values to non-integer.
Can you cast your value from your web page to a real?|||That worked! Thanks - had to multiplay by 1.0
Simple as that
Thanks
calculation problem
We have time dimension (month, week)
and fact table, total_revenue, no_of_work_day, order, order type....We added a calculated member : Ave revenue/work_day
Expression: "[Measures].[Tot Revenue]/[Measures].[No Of Work Day]"
in BI studio, but result is wrong.
Something wrong with 'no_of_work_day' , but how to correct it?
Thank you very much for any help.
In spite of using calculated member inside cube, try to create a named calculation inside datasourceview!?
In the table of datasourceview, right-click and add a named calculation a insert your formula TotRevenue/NoOfWorkDay...
Regards!
|||Can you show us your mdx query?
You try using the SUM(...) function on the measures members and dividing with it...
I would also like to say that you can create your calculated member in the cube...
Regards,
I tried using named calculation, it works. Great!
What is different between named calculation and calculate command inside cube?
I really appreciated your help.
|||
Dear Olap_user,
Always try to use named calculations... only when you need to calculate inside aggregations you use calculated member. The big advantage of using named calculation is that the system spend time to do calculates only once, and with calculated member each time you query the cube. So:
Named Calculation > each time your process cube
Calculated member > each time you query the cube!
Helped you?
Regards!!!
|||Thank you very much for the detail explanation, using Named Calculation is better for the performance.Your explanation is very helpful.
Thanks a lot.
Tuesday, February 14, 2012
Calculating percentages
I am creating a report like this.
I have totals by SalesPerson.
FOr each salesperson section, I have a total for the type of orders they have such as
Salesperson Code Total Sales
XXXX 1000.00 ( this is sum field by SalesPerson). This is group section
Type of order Sales$ for order % of total
Retail 300 (Sum field again by SP and Type of Order) Group Section
Resale 500
Other 200
I am trying to calculate the % of total field for each order type as Sales$per Order/TotalSales per Salesperson, however when I put in the expression it is using the Total Sales for the whole report and it comes up with a low number. DO any of you have any ideas on how to make this work, so that I can calculate the correct percentage ?
Thanks
In the percentage expression, add the grouping scope for the data that you would like the total sales to aggregate over. For example,=Sum(Fields!Sales.Value)/Sum(Fields!Sales.Value, "SalesPerson") * 100
Ian