SQL: maintenance plan delete after server rename

In a previous post I spoke about changing your database server name. If you created a maintenance plan, you might notice that the plan will fail. This is because the connection of your maintenance plan could be changed.

You can delete the maintenance plan by executing the following T-SQL (just change the Maintenance plan name:

DECLARE @PlanID AS VARCHAR(255)

BEGIN TRAN DeleteOldMaintenancePlans

SELECT @PlanID = id
FROM sysmaintplan_plans
WHERE name LIKE 'MaintenancePlan Name'

DELETE FROM sysmaintplan_log
    WHERE plan_id = @PlanID

DELETE FROM sysmaintplan_subplans
    WHERE plan_id = @PlanID

DELETE FROM sysmaintplan_plans
    WHERE id = @PlanID

IF @@ERROR = 0
 COMMIT TRAN DeleteOldMaintenancePlans
ELSE
 ROLLBACK TRAN DeleteOldMaintenancePlans

GO

After this you can manually delete the job which was associated with the maintenance plan.

Thx to SQLLearnings

SQL: changing your database server name

When you change the name of your server which is running SQL, you should also make sure that SQL gets updated with this new name. Proceed with the following procedure:

  • execute the command: select @@servername
    this command will return the current servername stored in SQL
  • execute the command: sp_dropserver ‘servername‘
    in which servername is the name that you got from the previous step
  • execute the command: sp_addserver ‘new servername’
  • restart the “ sql server”  service and the “ sql server agent” service
  • execute the command: select @@servername
    to verify everything went just fine :-)

Powershell: Executing a SQL Query and displaying results

 
$SqlQuery = "<Select Query>"

#Open a SQL Connection
$SQLconnection = New-Object system.Data.SqlClient.SqlConnection
$SQLconnection.Connectionstring = "<ConnectionString>"
$SQLconnection.Open()

$SQLCommand = New-Object system.Data.SqlClient.SqlCommand
$SQLadapter = New-bject System.Data.SqlClient.SqlDataAdapter 
$sqlcommand
$SQLdataset
 = New-Object System.Data.DataSet

$SQLCommand.CommandText = $SqlQuery
$SQLCommand
.Connection = 
$sqlconnection

$SQLadapter.Fill($SQLdataSet) | Out-Null
$SQLdataset.Tables[0] | ft

$SQLconnection.Close()

Identify SQL Server version

Some TSQL command to identify the version of SQL you are running:

SQL Server 6.5
SELECT @@VERSION

Version Number

Service Pack

6.50.479

SQL Server 6.5 Service Pack 5a (SP5a) Update

6.50.416

SQL Server 6.5 Service Pack 5a (SP5a)

6.50.415

SQL Server 6.5 Service Pack 5 (SP5)

6.50.281

SQL Server 6.5 Service Pack 4 (SP4)

6.50.258

SQL Server 6.5 Service Pack 3 (SP3)

6.50.240

SQL Server 6.5 Service Pack 2 (SP2)

6.50.213

SQL Server 6.5 Service Pack 1 (SP1)

6.50.201

SQL Server 6.5 RTM


SQL Server 7.0
SELECT @@VERSION

Version Number

Service Pack

7.00.1063

SQL Server 7.0 Service Pack 4 (SP4)

7.00.961

SQL Server 7.0 Service Pack 3 (SP3)

7.00.842

SQL Server 7.0 Service Pack 2 (SP2)

7.00.699

SQL Server 7.0 Service Pack 1 (SP1)

7.00.623

SQL Server 7.0 RTM (Release To Manufacturing)

SQL 2000
SELECT SERVERPROPERTY(‘productversion’), SERVERPROPERTY (‘productlevel’), SERVERPROPERTY (‘edition’)

Release

Sqlservr.exe

RTM

2000.80.194.0

SQL Server 2000 SP1

2000.80.384.0

SQL Server 2000 SP2

2000.80.534.0

SQL Server 2000 SP3

2000.80.760.0

SQL Server 2000 SP3a

2000.80.760.0

SQL Server 2000 SP4

2000.8.00.2039

SQL 2005
SELECT SERVERPROPERTY(‘productversion’), SERVERPROPERTY (‘productlevel’), SERVERPROPERTY (‘edition’)

Release

Sqlservr.exe

RTM

2005.90.1399

SQL Server 2005 Service Pack 1

2005.90.2047

SQL Server 2005 Service Pack 2

2005.90.3042

SQL Server 2005 Service Pack 3

2005.90.4035

SQL 2008
SELECT SERVERPROPERTY(‘productversion’), SERVERPROPERTY (‘productlevel’), SERVERPROPERTY (‘edition’)

Release

Sqlservr.exe

RTM

2007.100.1600.0

SQL Server 2008 Service Pack 1

2007.100.2531.0

SQL Integration services: “Access is denied” when running SSIS package

We had a problem with executing a SQL Job which runs a SSIS Package. Whenever the job started we would get the following error:

Executed as user: <domain>\<user>. Microsoft (R) SQL Server Execute Package Utility  Version 10.0.1600.22 for 64-bit  Copyright (C) Microsoft Corp 1984-2005. All rights reserved.    Started:  09:13:01  Error: 2009-08-05 09:13:02.85     Code: 0xC002F304     Source: <source> from SFTP Execute Process Task     Description: An error occurred with the following error message: "Access is denied".  End Error  DTExec: The package execution returned DTSER_FAILURE (1).  Started:  09:13:01  Finished: 09:13:03  Elapsed:  1.843 seconds.  The package execution failed.  The step failed.

The package was executing a batch file which in his turn starts an SFTP connection and downloads some files.
It seems that it has all to do with the fact that we are running on a x64 bits server with x64 SQL Server.

To resolve the problem open the job and then edit the job step. Next click on the Execution Options Tab. Finally enable the “Use 32 bit runtime” option. This should resolve your problem.

SQL Job Properties

Weird thing is, that when the owner of the job is a local administrator, the job will not fail and will execute properly.

More information can be found here and here.

SQL: Microsoft SQL Server, error:916

I created a SQL User named UserA which was DB_Owner of 1 database. When I connected to this database with SQL Authentication I received the following error:

The server principal “User A” is not able to access the database “DatabaseA” under the current security context. (Microsoft SQL Server, error:916)

image

To resolve this error I logged in as SQL User UserA, and open theVObject Explorer Details View (press F7). I then right Clicked on the column header and de-selected ‘Collation’. Refresh your databases again and now it should work.

EWA: Error Data Refresh Failed

I’ve been struggling for quite a long time with Excel Web Access in combination with a SQL Analysis Server and SharePoint.
The problem is that I am able to display an excel file (which is in a SharePoint web part), but whenever I choose to refresh the connection I get the following error:

Unable to retrieve external data for the following connections:
[ODC File]
The data sources may be unreachable, may not be responding, or may have denied you access.
Verify that data refresh is enabled for the trusted file location and that the workbook data authentication is correctly set.

Here is a screenshot:

EWA: Data Refresh Failed

Finally today I got this error resolved.

First of all I did all the action that MVP – Ton Stegeman did in his blog about this subject. Check it out here (follow all 4 parts). He ends in part 3 with the error I have, but there was no solution provided.

First of all I needed to make sure that Kerberos is working and did not have a double hop problem, and that I could access the SSAS server and his cube. For that I added a SQL Server 2005 Analysis Services Filter Web Part and specified the same ODC file. It worked great (I could select a dimension and a Hierarchy).

The problem with this error is that I am running MOSS and SSAS both on a Windows 2008 Server (2 different servers btw.). You might think that it should not be any different than a 2003 server, but Server 2008 is “AES aware” (Advanced Encryption System). There is a problem with AES aware systems like W2K8, Vista and the use of Kerberos.
To get it to work, you will have to follow the steps below:

  1. Open the following file in Notepad: “c:\Program Files\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Config\msmdsrv.ini”
  2. There is a section called Security, which looks like this:
        <Security>
            <DataProtection>
                <RequiredProtectionLevel>1</RequiredProtectionLevel>
            </DataProtection>
            <AdministrativeDataProtection>
                <RequiredProtectionLevel>1</RequiredProtectionLevel>
            </AdministrativeDataProtection>
            <RequireClientAuthentication>1</RequireClientAuthentication>
            <SecurityPackageList/>
            <DisableClientImpersonation>0</DisableClientImpersonation>
            <BuiltinAdminsAreServerAdmins>1</BuiltinAdminsAreServerAdmins>
            <ServiceAccountIsServerAdmin>1</ServiceAccountIsServerAdmin>
            <ErrorMessageMode>2</ErrorMessageMode>
            <CellPermissionMode>0</CellPermissionMode>
        </Security>

  3. Change the tag <DataProtection> and <AdministrativeDataProtection>, so it looks like this:

        <Security>
            <DataProtection>
                <RequiredProtectionLevel>0</RequiredProtectionLevel>
            </DataProtection>
            <AdministrativeDataProtection>
                <RequiredProtectionLevel>0</RequiredProtectionLevel>
            </AdministrativeDataProtection>
            <RequireClientAuthentication>1</RequireClientAuthentication>
            <SecurityPackageList/>
            <DisableClientImpersonation>0</DisableClientImpersonation>
            <BuiltinAdminsAreServerAdmins>1</BuiltinAdminsAreServerAdmins>
            <ServiceAccountIsServerAdmin>1</ServiceAccountIsServerAdmin>
            <ErrorMessageMode>2</ErrorMessageMode>
            <CellPermissionMode>0</CellPermissionMode>
        </Security>

  4. Stop and restart Analysis Services
  5. Then edit your ODC file and add the following to the connection strong:

    ”;SSPI=Kerberos;Protection Level=Connect” (without the quotes)

Now try again.

Tip: 
-  restart IIS every time you make a change in your ODC file.