Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Monday, March 19, 2012

Currency format when exporting to excel

Hi,

I have a problem with the number format when i export my reports to excel with Reporting Services. I set numbers as currency with the command FormatCurrency() in visual studio, but when i export the report to excel, the numbers are considered as text.

Does anyone have a solution?
Thanks in advance.

Use the Format property on the cell/textbox, for currency the format string should be c<number decimal places>, i.e. c0 prints the currency figure with no decimal places. Once you have done this, remove the FormatCurrency() function from the expression as it overrides anything you have in the Format property. The reason the FormatCurrency() does not work when exporting to Excel is because its return value is a string, so Excel is confused - is it a currency or is it a string?

|||Thanks a lot, it works perfectly!!!! I'm so releaved

Friday, February 24, 2012

Cube deployment

Hi,

I am trying to silently deploy a cube within my install using the following command line:

"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Microsoft.AnalysisServices.Deployment.exe" "c:\MyCubesFolder\Cubes.asdatabase" /s

but i keep getting the error message:

Reading input files...

Done

The 'Name' property cannot contain any of the following characters: . , ; ' ` : / * | ? " & % $ ! + = ( ) [ ] { } < >

The file contains URLs in some name properties with the ':' character. I tried removing those URLs but that didnt help.

Also, I was able to deploy the cube successfully using the same file from the Microsoft.AnalysisServices.Deployment.exe IDE - so I know my file is ok.

But I want to wrap this into the install and deploy it silently. Any ideas?

Thanks

Are you doing all steps from the list below ?

To create a XMLA script from solution project you have to buld solution (generas .asdatabase file), then run deployment wizard with option specifying that you want to generate XMLA script. Step by step guide:

Run script to build solution:
devenv.exe YourSolution.sln /build development /out BuildOutputLog.log
Instead of /build you can specify /rebuild
Instead of development you can specify other soluction configuration, like: Release
Example: "c:\Program Files\Microsoft Visual Studio 8\Common7\ide\devenv.exe" "c:\documents and settings\vidas\my documents\visual studio 2005\projects\MySolution\MySolution.sln" /build development /out BuildOutputLog.log Optionally run deployment wizard in answer mode to generate deployment script configuration. This is interactive step and can be done just once. Command:
Microsoft.AnalysisServices.Deployment.exe MySolution.asdatabase /a
Here /a runs deployment wizard in answer mode.
Example: Microsoft.AnalysisServices.Deployment.exe "c:\documents and settings\Vidas\My Documents\Visual Studio 2005\Projects\MySolution\MySolution\bin\MySolution.asdatabase" /a Run deployment wizard command line script to generate XMLA file:
Microsoft.AnalysisServices.Deployment.exe MySolution.asDatabase /d /o:c:\MySolutionXMLAScript.xmla
Example: Microsoft.analysisServices.Deployment.exe "c:\Documents And Settings\Vidas\My Documents\Visual Studio 2005\Projects\MySolution\MySolution\bin\MySolution.asDatabase" /d /o:c:\MySolutionXMLAScript.xmla|||

I think most of those names will refer to internal SSAS objects like annotations, so that is not likely to be the issue, specially if you can deploy from the UI. The ouput from silently deploying Adventure Works on my laptop look like the following. Notice that the line where you are getting hte error is where it should be attempting to connect to the target server. This is probably where the illegal character is. This should be in your .deploymentOptions file and it would depend on which configuration you had build last.

C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE>microsoft.analysisservices.deployment.exe "C:\Data\Projects\SSAS 2005 Samples\Enterprise\bin\Adventure Works DW.asdatabase" /s

Reading input files...
Done
Connecting to the localhost\sql05 server
Database, Adventure Works DW, found on server, localhost\sql05. Applying configuration settings and options...
Analyzing configuration settings...
Done
Analyzing optimization settings...
Done
Analyzing storage information...
Done
Analyzing security information...
Done
Generating processing sequence...
Deploying the 'Adventure Works DW' database to 'localhost\sql05'.
Done

Hope this helps

|||

Thanks for the replies

During install, I am updating the .deploymentOptions file with the ip address and instance where of the Analysis server where the cube is to be deployed. When I replaced the ip address with the system name, it seemed to work fine - looks like it cannot deal with the "." in the ip address - defect?

|||I think it might be. You should log this at http://connect.microsoft.com, it sounds like it might be an issue with the deployment wizard.

Cube deployment

Hi,

I am trying to silently deploy a cube within my install using the following command line:

"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Microsoft.AnalysisServices.Deployment.exe" "c:\MyCubesFolder\Cubes.asdatabase" /s

but i keep getting the error message:

Reading input files...

Done

The 'Name' property cannot contain any of the following characters: . , ; ' ` : / * | ? " & % $ ! + = ( ) [ ] { } < >

The file contains URLs in some name properties with the ':' character. I tried removing those URLs but that didnt help.

Also, I was able to deploy the cube successfully using the same file from the Microsoft.AnalysisServices.Deployment.exe IDE - so I know my file is ok.

But I want to wrap this into the install and deploy it silently. Any ideas?

Thanks

Are you doing all steps from the list below ?

To create a XMLA script from solution project you have to buld solution (generas .asdatabase file), then run deployment wizard with option specifying that you want to generate XMLA script. Step by step guide:

Run script to build solution:
devenv.exe YourSolution.sln /build development /out BuildOutputLog.log
Instead of /build you can specify /rebuild
Instead of development you can specify other soluction configuration, like: Release
Example: "c:\Program Files\Microsoft Visual Studio 8\Common7\ide\devenv.exe" "c:\documents and settings\vidas\my documents\visual studio 2005\projects\MySolution\MySolution.sln" /build development /out BuildOutputLog.log Optionally run deployment wizard in answer mode to generate deployment script configuration. This is interactive step and can be done just once. Command:
Microsoft.AnalysisServices.Deployment.exe MySolution.asdatabase /a
Here /a runs deployment wizard in answer mode.
Example: Microsoft.AnalysisServices.Deployment.exe "c:\documents and settings\Vidas\My Documents\Visual Studio 2005\Projects\MySolution\MySolution\bin\MySolution.asdatabase" /a Run deployment wizard command line script to generate XMLA file:
Microsoft.AnalysisServices.Deployment.exe MySolution.asDatabase /d /o:c:\MySolutionXMLAScript.xmla
Example: Microsoft.analysisServices.Deployment.exe "c:\Documents And Settings\Vidas\My Documents\Visual Studio 2005\Projects\MySolution\MySolution\bin\MySolution.asDatabase" /d /o:c:\MySolutionXMLAScript.xmla|||

I think most of those names will refer to internal SSAS objects like annotations, so that is not likely to be the issue, specially if you can deploy from the UI. The ouput from silently deploying Adventure Works on my laptop look like the following. Notice that the line where you are getting hte error is where it should be attempting to connect to the target server. This is probably where the illegal character is. This should be in your .deploymentOptions file and it would depend on which configuration you had build last.

C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE>microsoft.analysisservices.deployment.exe "C:\Data\Projects\SSAS 2005 Samples\Enterprise\bin\Adventure Works DW.asdatabase" /s

Reading input files...
Done
Connecting to the localhost\sql05 server
Database, Adventure Works DW, found on server, localhost\sql05. Applying configuration settings and options...
Analyzing configuration settings...
Done
Analyzing optimization settings...
Done
Analyzing storage information...
Done
Analyzing security information...
Done
Generating processing sequence...
Deploying the 'Adventure Works DW' database to 'localhost\sql05'.
Done

Hope this helps

|||

Thanks for the replies

During install, I am updating the .deploymentOptions file with the ip address and instance where of the Analysis server where the cube is to be deployed. When I replaced the ip address with the system name, it seemed to work fine - looks like it cannot deal with the "." in the ip address - defect?

|||I think it might be. You should log this at http://connect.microsoft.com, it sounds like it might be an issue with the deployment wizard.

Cube Actions, how can I create a Command line action

In Analysis 2000 there was a command line action type, how can I do the same action in Analysis Services 2005?

Analysis 2000 command line action:

Defines an MDX statement that can be executed as a command line and displays the contents of the current directory:

"cmd /k dir"

Peter,

The DDL for AS2K5 still supports HTM and Command Line actions, but they are not exposed in the Business Intelligence Development Studio (BIDS). One work around that I have used is to create a URL action in BIDS and then save the cube definition and deploy it. Then you use SQL Server Management Studio to generate an ALTER CUBE script to an XMLA query window. Do a search on the script to find your action and then just change the type as show here:

Original script (segment with action definition)

<Action xsi:type="StandardAction">

<ID>Action</ID>

<Name>Command Line Action</Name>

<TargetType>Cells</TargetType>

<Type>URL</Type>

<Expression>"cmd /k dir"</Expression>

</Action>

Modified script

<Action xsi:type="StandardAction">

<ID>Action</ID>

<Name>Command Line Action</Name>

<TargetType>Cells</TargetType>

<Type>CommandLine</Type>

<Expression>"cmd /k dir"</Expression>

</Action>

Then just execute your script and the action type will be set to Command Line.

HTH,

- Steve

|||

Steve,

When I modify the script It still not works?

<Action xsi:type="StandardAction" dwd:design-time-name="f542b1b2-b2b6-4bf8-9903-63150db6ed15">
<ID>Action 1</ID>
<Name>CMD</Name>
<Description></Description>
<Caption></Caption>
<TargetType>Cells</TargetType>
<Target></Target>
<Condition></Condition>
<Type>CommandLine</Type>
<Application></Application>
<Expression>"cmd /k /dir"</Expression>
</Action>

When I change it back into URL the action works fine.

<Action xsi:type="StandardAction" dwd:design-time-name="f542b1b2-b2b6-4bf8-9903-63150db6ed15">
<ID>Action 1</ID>
<Name>CMD</Name>
<Description></Description>
<Caption></Caption>
<TargetType>Cells</TargetType>
<Target></Target>
<Condition></Condition>
<Type>Url</Type>
<Application></Application>
<Expression>"http://www.mywebsite.com"</Expression>
</Action>

|||

Peter,

I believe the problem is in the "Expression" you supplied to the command line action. It should be "cmd /k dir" and you have "cmd /k /dir"

<Expression>"cmd /k /dir"</Expression>

Sunday, February 19, 2012

CTE in OLE DB Command Data Flow Transformation

I am trying to use a CTE in an OLE DB Command data flow transformation object. However, when I enter the cte and corresponding query in the SqlCommand field of the OLE DB command editor dialog, I get a syntax error. Can CTE's be used data flow objects? I have been able to use them in an Execute SQL Control Flow Item, but not in any data flow item.

I was able to paste a query using a CTE inside of the OLE DB Command with no problem(just a quick copy and paste- no parameters invloved); then I think CTEs are not the problem. May be is the parameter mapping or something else. Could you post the query and the error so folks around here can get a better picture of the problem.|||

Thank you for your reply. I was able to successfully use a CTE in an OLE DB Source data flow component. I had a silly syntax error.

I am now running into a problem using a CTE in an OLEDB command object. There are two levels of the problem.

1. I can use a straight forward CTE in an OLEDB command object if I use the "Native OLE DB\SQL Native Client" provider.

For example, this works:

/**BEGIN QUERY**/

with TestCTE2(prod_id) as
(
select ProductID from Production.Product p
where p.ProductID = 321
)

select prod_id from TestCTE2

/**END QUERY**/

but if I try to modify and use a parameter, like:

/**BEGIN QUERY**/

with TestCTE2(prod_id) as
(
select ProductID from Production.Product p
where p.ProductID= ?
)

select prod_id from TestCTE2

/**END QUERY**/

I get the following error:

Error 2 Validation error. Data Flow Task: OLE DB SQL Native Client [863]: An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Syntax error, permission violation, or other nonspecific error". Package.dtsx 0 0

2. If I try and use a CTE in an OLE DB Command data flow object using the "Native OLE DB\Microsoft OLE DB Provider for SQL Server" provider

I can't enter the first query from above at all, i get the following error message:

Error 1 Validation error. Data Flow Task: OLE DB provider for SQL Server [875]: An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80040E14 Description: "Statement(s) could not be prepared.". An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80040E14 Description: "Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.". An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80040E14 Description: "Incorrect syntax near the keyword 'with'.". Package.dtsx 0 0

which I find curious, because there is no previous stataments.

The above queries are going against the adventureworks database.

Any further insight? Thanks for your help.

Kyle Key

|||

Kyle,

That was the test I performed in my initial post; and you are right, as soon as you add a parameter it throws an error.

Just out of curiosity; what is your ultimate goal when trying to combine a CTE and an OLEDB command? Are you trying to update rows or what?

For performance reasons, I try to stay away of OLE DB Commands. In some cases, you could replace the OLE DB Command by a OLEDB Destination that point to a staging table and then in control flow you can use a Execute SQL task to execute the same SQL statement using staging table as a reference to constraint which rows should be affected. The advantage of this procedure is to execute the sql statement only once; instead of 1 per row when an OLE DB command is used.

This does not answer your question but could give you other options

|||

I'm using the CTE to flatten out a hierarchy. I can get a list of nodes in a hierarchy, and was hoping to use the OLE DB Command transformation to loop through those nodes to get the leaf nodes and update those leaf nodes. I was going under the assumption that using a staging/temporary table would be costly to performance, but I may have to rethink my approach. I guess getting it done is better than spinning my wheels.

Do you know if the problem I'm seeing is a bug or functioning as designed? I was going to install the latest CTP for SP2 and see if the behavior is any different.

|||

I actually don't know if that would be fixed in SP2. But I found a work around; just place the SQL Statement inside of a stored procedure and then called it from the OLE DB Command.

I ran a test against AdventureWorks, see here for more details:

http://rafael-salas.blogspot.com/2006/12/passing-parameters-to-ole-db-command.html

Pleas, let me know if you found a diffrent approach.

thanks

|||

Kyle Key wrote:

I'm using the CTE to flatten out a hierarchy. I can get a list of nodes in a hierarchy, and was hoping to use the OLE DB Command transformation to loop through those nodes to get the leaf nodes and update those leaf nodes. I was going under the assumption that using a staging/temporary table would be costly to performance, but I may have to rethink my approach. I guess getting it done is better than spinning my wheels.

Do you know if the problem I'm seeing is a bug or functioning as designed? I was going to install the latest CTP for SP2 and see if the behavior is any different.

Kyle,

This probably isn't the optimum way of going about this. As Rafael says the OLE DB Command is not at all performant (we can elaborate as to why if needs be).

In your case it does seem as though using T-SQL will be a better bet. If you really do want to execute this functionality in the data-flow and not have to operate on the data row-by-row a la the OLE DB Command then you could use an asychsronous script component.

It would help to understand the problem better. How are your values in the data-flow being used to update the existing data?

-Jamie