Saturday, February 25, 2012
Among Numeric and Float
can any body help
thanx in advance...probably Float, because you can set the scale and precision.
e.g. Float(10,5) will show 1234.00023 (five decimal places or as many as you need)
Sunday, February 19, 2012
AMO - measure numeric Value
How can i do this using AMO ?, i'm wondering if i can do this from the FactTable's (Data Table) DataColumns, but there is no metadata that tells me if the values there are or not valid numeric measures.
Regards Lisber.
Hi. I don't know the answer to your AMO question. However, I do know that you can get the metadata about your fact table from the system views in SQL Server 2005. For example, if you want to know the columns in a fact table with data type Money or Float the following query works against the sales fact in AdventureWorks schema:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'FactInternetSales'
AND (DATA_TYPE = 'float' OR DATA_TYPE = 'money')
A more extensive article about SQL Server 2005 metadata is available from Database Journal at this link:
http://www.databasejournal.com/features/mssql/article.php/3508881
Hope this helps - Paul Goldy
|||Thanks for your answer Paul,
The Problem that i have needs another solution because :( , i'm creating the cube dynamically:
I have the DataTable related to the fact table, but when i start creating the measures i need to do this:
(Copied from AdventureWorks - AMO Example)
meas.Source = CreateDataItem(db.DataSourceViews[0], "FactInternetSalesReason", "SalesOrderLineNumber");
but when i'm doing this dynamically i need to verify if "SalesOrderLineNumber" is or not a measure.
So in my case a have the factTable lets say "FactInternetSalesReason ", and i can make a loop through all of its dataTableColumns, here is where i need to know if that column is or not a valid measure in order to add it.
I'm following the AdventureWorks example, but as far as i can see all the cube creation is hard coded.|||HI. I understand the issue better now. Sorry, but I don't know how to determine if a column is a valid measure in your scenario. Paul Goldy|||Hey Lisber..
I'm not sure i fully understand, but what i gather is you want to add the measures from the fact table if it is some sort of numeric datatype in the table?
If that's the case, you've already got the datatable, so you can do something like this:
Dim DC as new DataColumn
For each DC in YOURDATASET.tables("YOURTABLENAME").Columns
If DC.DataType.Name = "Int32" '//Just an example
'//Add your measure here
End if
Next DC
If that's not what you mean, sorry :) If that is what you mean, and need more additional information, let me know..
C|||
Hi
Chris !, exactly i was thinking in the solution you described before , but i was having some troubles, here is the code that i use to figure out if a
data column is or not a measure ( ie, if its numeric ).
// 1o I make a loop through all the columns of my fact table ("FactResellerSales"), here is the code:
private void showMeasures()
{
for (int i = 0; i < this.dataSet.Tables["FactResellerSales"].Columns.Count; i++)
{
DataColumn column = this.dataSet.Tables["FactResellerSales"].Columns;
if (isMeasure(column.DataType))
Response.Write(column.ColumnName + "<br>");
}
}
private bool isMeasure(Type type)
{
switch (type.Name)
{
case "Int16": return (true);
case "Int32": return (true);
case "Int64": return (true);
case "Decimal": return (true);
case "Double": return (true);
case "Byte": return (true);
case "Boolean": return (true); // see better
default: return (false);
}
}
If anyone knows another way to figure out which columns in the fact table are measures or not, please tell me, because this solution is for sure not the best one !
Thursday, February 9, 2012
alternative function for to_char in sql server
Is there any alternative function for to_char in sql server 2005(T-SQL) that
converts numeric to character in the specified format?
to_char(5,'09')
will result in 05 (in oracle)
to_char(10,'09')
will result in 10 (in oracle)
ThanksJP
No, there isn't
DECLARE @.c AS INT
SET @.c=9
SELECT CASE WHEN LEN(@.c)=1 THEN '0'+ CAST(@.c AS VARCHAR(2))
ELSE CAST(@.c AS VARCHAR(2)) END
"JP" <JP@.discussions.microsoft.com> wrote in message
news:83C4046F-70C8-463B-B533-3D3C181D96DA@.microsoft.com...
> Hi,
> Is there any alternative function for to_char in sql server 2005(T-SQL)
> that
> converts numeric to character in the specified format?
> to_char(5,'09')
> will result in 05 (in oracle)
> to_char(10,'09')
> will result in 10 (in oracle)
> Thanks
>|||You dn't have a direct function.
Maybe you can use something like this
declare @.a int ,@.no_of_digits int
set @.a = 10 -- value
set @.no_of_digits = 2 -- No of digits you want to have in the final string
select right(replicate('0',@.no_of_digits) + cast(@.a as
varchar(30)),@.no_of_digits)
Hope this helps.
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/