Showing posts with label SQL Server. Show all posts
Showing posts with label SQL Server. Show all posts

Friday, 7 December 2012

Error Value: 2147942523 on Scheduled Task for Powershell


Situation: 
One of our clients where struggling with SSRS2008 R2 in SharePoint 2010 integrated mode (two server farm, both 64-bit Windows 2008 R2).
It is well known that this version SSRS 2008 R2 (v10) delivers a really bad performing webpart on the first report that is requested at the beginning of the day. For your information: The older v9 version performs much better as well as the newer version (of SSRS 2012).
However, I tried several solutions, without any luck. I found a solution on Pavel Pawlowski's blog (http://www.pawlowski.cz/2011/07/solving-issue-long-starting-report-ssrs-2008), which suggest to run a powershell script to stop/start the SSRS service, and load a report in a webclient (read more details on his post).
Problem:
I tried to run the scheduled task with the following statement:
"powershell.exe -noprofile -executionpolicy RemoteSigned -file c:\dnm\RestartSSRS.ps1"
It didn't work, it shows the following errors:
Task category: Action failed to start
Description: Task Scheduler failed to launch action “powershell.exe -noprofile -executionpolicy RemoteSigned -file c:\dnm\RestartSSRS.ps1? in instance “{46caf0b2-50df-49ad-90d6-0f4f9fd203ae}” of task “\SSRS Recycle”. Additional Data: Error Value: 2147942523.
Then I get:
Task category: Action start failed
Description: Task Scheduler failed to start instance “{46caf0b2-50df-49ad-90d6-0f4f9fd203ae}” of “\SSRS Recycle” task for user “customerdomain\Administrator” . Additional Data: Error Value: 2147942523
Solution:
I turns out that in this situation the Task Scheduler cannot fire the 64-bit version of powershell (which powershell.exe will do). You need to explicit point to the 32-bit version.
What I did was, edit the scheduled task, go to the action-tab and open the edit action window of the action.
On 'Program/script', I entered: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
On 'Add arguments (optional), I entered: -noprofile -executionpolicy RemoteSigned -file c:\myScripts\RestartSSRS.ps1

Done, that solved the "Error Value: 2147942523" problem for me.
And the solution Pavel Pawlowski gave, works also! All credits to him!

Wednesday, 24 October 2012

Restore failed for Server '' (MS SQL Server 2008 R2)

Problem
Today, I tried to restore a MS SQL Server 2008 R2 backup file. From a production server, I made a backup file. I tried to restore that backup on a named instance of SQL Server on a test server (on a physical other machine), to do some tests on the data without disturbing the live environment. The database didn't exist on the restore location.
To get the picture correct: on the test server, I have a default MS SQL Server instance and an extra, named instance. The restore was performed on the named instance!
It failed...
I got the following error:
System.Data.SqlClient.SqlError: The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\pfwork.mdf'. (Microsoft.SqlServer.Smo)
Strange enough, I was logged in with full administrator privileges.
Solution
I found some possible reasons at http://stackoverflow.com/questions/7031792/sql-server-restore-error-access-is-denied, but that was not the case in my situation.
Having a closer look at the message above opened my eyes. It was trying to create the database file on the data folder of the default instance, instead of the data folder of the named instance. That location would be C:\Program Files\Microsoft SQL Server\MSSQL10_50.DEVSSRS\MSSQL\DATA\.
So, when you start a restore from a device file to a (not existing) database, verify the location in the 'Options' page of the 'Restore Database' window. In my case it was pointing to the default SQL Server instance, despite the default file location of the named instance where pointing to the correct place.

Tuesday, 25 September 2012

Report Server: Show/hide textbox by an expression

Today I was struggling with hiding a textbox on a report (in Report Builder) by using an expression. I tried to evaluate the number of subfunctions of a certain person. The evaluation worked, but the textbox didn't show up when 1 or more subfunctions were available.
The expression was:
=IIf((Count(Fields!Uid.Value, "dsSubFunctions")<1),False,True)
WRONG! The property you will set is named 'Hidden', so it's just the other way around:
=IIf((Count(Fields!Uid.Value, "dsSubFunctions")<1),True,False)
And stupid of me, it is just written right above the expression-textbox: 'Set the expression for: Hidden'

Anyway, just thought to share it, in case there are some more (lazy) programmers who don't read every single line of text Microsoft shows you :)

Thursday, 21 October 2010

Cannot connect to database master at SQL server

During installation of SharePoint 2010 the Configuration Wizard could not connect to the SQL Server database:
Cannot connect to database master at SQL server at SERVERNAME. The database might not exist, or the current user does not have permission to connect to it.
Several blogs where dealing with the permissions, which I checked, but they were well set. The actual problem was the TCP/IP setting of SQLServer. The TCP/IP protocol for the SQL Server was disabled (default setting on installation). Enabling this setting solved the problem.
Enabling can be done using the Sql Server Configuration Manager. Go to SQL Server Network Configuration > Protocols for MSSQLSERVER (or the named instance name you are using) en check the TCP/IP protocol status. This should be 'Enabled'.

So, if you are running into this error, check the user accounts settings as well as the TCP/IP settings of the SQL Server.

Update (23 August 2012): I just add an extra addition: Make sure that SQL server is listening on port 1433 (Thanks to Suolon)