Powershell function to get Sqlserver errorlog recent lines

I’ve started knocking up a function to return the last few lines of a sqlserver errorlog.

This is a little way from being finished….but I’ve already found it quite handy

function get-sqlerrorlog { 

  [CmdletBinding()]	
  Param( 
      [String] [alias("computer")] $ComputerName,
      [Int] [alias("lines")] $NumberOfLines = 5
  )

  write-verbose "Running function $([string]$MyInvocation.MyCommand.name)"
  
  Write-verbose "`$ErrorLogFolder: $ErrorLogFolder"

  $ErrorLogFolder = dir sqlserver:\sql\$ComputerName 

  # Todo: need to work out how it works more > 1 named instance. This just picks 1st
  [string]$ErrorLogFolder = $($ErrorLogFolder | select -first 1).errorlogpath
  Write-verbose "`$ErrorLogFolder: $ErrorLogFolder"

  $ErrorLogFolder = $ErrorLogFolder.replace(':', '$')
  Write-verbose "`$ErrorLogFolder: $ErrorLogFolder"

  $ErrorLogFolder = '\\' + $ComputerName + '\' + $ErrorLogFolder
  Write-verbose "`$ErrorLogFolder: $ErrorLogFolder"

  # Todo: it might be that the get-content could be speeded up by retrieving less lines
  # Todo: seperate this bit out into seperate function ?  
  get-content "$ErrorLogFolder\ERRORLOG" | select -last $NumberOfLines                                                                
 
}
set-alias gsel get-sqlerrorlog

how to edit lots of files and keep a log

First I built a list of files

FileList=dir -recurse C:\temp\folderx -Attributes !Directory | 
    ? name -notlike '*exe' | 
    ? name -notlike '*dll'| select fullname

Then for each one, record the name to a log file, edit it and prompt for and store a comment

foreach ($F in $Filelist) {
    $F.Fullname >> commentlog.txt
    $File = $F.Fullname
    C:\Progra~2\vim\vim74\gvim.exe $File
    $Comment = read-host "Changes made to $File"
    $comment >> commentlog.txt
}

getting a list of aliases ordered by the aliasee

This is fairly trivial…and I’ve no idea if ‘aliasee’ is a real word or not, but I found this quite useful today:

get-alias | select ResolvedCommand, name | sort -property resolvedcommand

On my laptop, this gives:


ResolvedCommand Name --------------- ---- Add-Content ac Add-PSSnapin asnp Clear-Content clc Clear-History clhy Clear-Host cls Clear-Host clear Clear-Item cli Clear-ItemProperty clp Clear-Variable clv Compare-Object diff Compare-Object compare Connect-PSSession cnsn Convert-Path cvpa Copy-Item cp Copy-Item copy Copy-Item cpi Copy-ItemProperty cpp Disable-PSBreakpoint dbp Disconnect-PSSession dnsn Enable-PSBreakpoint ebp Enter-PSSession etsn Exit-PSSession exsn Export-Alias epal Export-Csv epcsv Export-PSSession epsn ForEach-Object foreach ForEach-Object % Format-Custom fc Format-List fl Format-Table ft Format-Wide fw Get-Alias gal get-cal cal Get-ChildItem dir Get-ChildItem ls Get-ChildItem gci Get-Command gcm Get-Content cat Get-Content gc Get-Content type get-functions getf Get-History history Get-History ghy Get-History h Get-Item gi Get-ItemProperty gp Get-Job gjb Get-Location pwd Get-Location gl Get-Member gm Get-Module gmo get-os gos Get-Process gps Get-Process ps Get-PSBreakpoint gbp Get-PSCallStack gcs Get-PSDrive gdr Get-PSSession gsn Get-PSSnapin gsnp Get-Service gsv Get-Unique gu Get-Variable gv Get-WmiObject gwmi Group-Object group help man Import-Alias ipal Import-Csv ipcsv Import-Module ipmo Import-PSSession ipsn Invoke-Command icm Invoke-Expression iex Invoke-History r Invoke-History ihy Invoke-Item ii Invoke-Locate.ps1 locate Invoke-NullCoalescing ?? Invoke-RestMethod irm Invoke-WebRequest wget Invoke-WebRequest iwr Invoke-WebRequest curl Invoke-WmiMethod iwmi Measure-Object measure mkdir md Move-Item move Move-Item mv Move-Item mi Move-ItemProperty mp New-Alias nal New-Item ni New-Module nmo New-PSDrive mount New-PSDrive ndr New-PSSession nsn New-PSSessionConfigurationFile npssc New-Variable nv Out-GridView ogv Out-Host oh Out-Printer lp Pop-Location popd powershell_ise.exe ise Push-Location pushd Receive-Job rcjb Receive-PSSession rcsn Remove-Item rmdir Remove-Item del Remove-Item rd Remove-Item rm Remove-Item erase Remove-Item ri Remove-ItemProperty rp Remove-Job rjb Remove-Module rmo Remove-PSBreakpoint rbp Remove-PSDrive rdr Remove-PSSession rsn Remove-PSSnapin rsnp Remove-Variable rv Remove-WmiObject rwmi Rename-Item rni Rename-Item ren Rename-ItemProperty rnp Resolve-Path rvpa Resume-Job rujb Select-Object select Select-String sls Set-Alias sal Set-Content sc set-debug db Set-Item si Set-ItemProperty sp Set-Location sl Set-Location chdir Set-Location cd Set-PSBreakpoint sbp Set-Variable sv Set-Variable set Set-WmiInstance swmi Sort-Object sort Start-Job sajb Start-Process start Start-Process saps Start-Service sasv Start-Sleep sleep Stop-Job spjb Stop-Process kill Stop-Process spps Stop-Service spsv Suspend-Job sujb Tee-Object tee Trace-Command trcm Update-LocateDB.ps1 updatedb Wait-Job wjb Where-Object where Where-Object ? Write-Output write Write-Output echo

how to rdp to several desktops one after the other

For reasons that aren’t necessarily relevant, I wanted to use Remote Desktop to visit a list of servers1. I tried doing this:

foreach ($S in "server01", "server02, "server03") { 
    mstsc /f /V:$S
}

This works….but it immediately starts rdp sessions to each of the servers. This is fine in this example, where there are only 3 servers, but in real life I’ve got a list of twenty or so and I don’t really want to open 20-odd rdp sessions at once.

What I did instead to force it do the rdp’s sequentially was this:

foreach ($S in "server01", "server02, "server03") { 
    mstsc /f /V:$S
    $ThrowAway = read-host "Hit Return"
}

  1. I'd really rather not do this, but I can't find a safe and seen-to-be-safe way of doing what I want to do through PowerShell or any other automated tool 

how to extract tweets about...

This was the Powershell code I used to create the all the podcasts I’ve ever tweeted about post.

I downloaded the tweets from Twitter itself - I think there was a link somewhere within ‘Settings’

The .csv file looks like this:

Tweets csv file

So the code is:

$PodTweets = Import-Csv c:temptweets.csv | ? text -like "*podcast*"

$TweetsAsHtml = foreach ($P in $PodTweets)
{
#   write-output $P.timestamp.Substring(0,10)

   # Splitting the tweet text into words to allow for the processing of urls
   $TweetTextAsArray = $P.text.split(" ")

   $TextWithLink=""

   foreach ($Word in $TweetTextAsArray)
   {
        if ($Word -like "http:*")
        {
            # if there is an expanded_url, then use that instead
            if ($P.expanded_urls -ne "")
            {
                $Word = $P.expanded_urls

                # for some reason the expanded url is sometimes repeated in the download
                if ($Word -like "*,*")
                {
                    $Word = $Word.split(",")[0]
                }
            }

            # re-format the URL as a link
            $Word = "`<a href=`"$Word`"`>$Word`<`/a`>"
        }
        $TextWithLink = "$TextWithLink$Word "


    }

    # create an object and output that
    $properties = @{'TweetDate'=$P.timestamp.Substring(0,10);
                    'TweetText'=$TextWithLink}

    $ReformattedTweets = New-Object -Type PSObject -Prop $properties

    write-output $ReformattedTweets

}

$TweetsAsHtml | fl | out-file -encoding ascii -FilePath x.txt -width 1000

show sql errorlog messages since a specified date

This almost speaks for itself…but it might be worth noting that:

  • I’m only interrogating the latest file here

  • it’s a teeny bit cumbersome - I would probably function-alize it

  • the big advantage here compared to the GUI is you can cut-and-paste it really easily

dir sqlserver:sql\the_server_name
$logs.readerrorlog(0) |
  where logdate -gt ([datetime]::ParseExact('25/02/2015 07:27:36',"dd/MM/yyyy HH:mm:ss",$null))  |
  select processinfo, text |
  ft -a -wrap

system databases not included in powershell sqlserver provider 'databases' folder

I hadn’t noticed this before.

If you do a dir listing of the databases for an instance within the Powershell Sqlserver provider, it doesn’t show the system databases

PS C:powershell> dir SQLSERVER:\SQL\my_pcinst2012\databases

Name                 Status          Recovery Model CompatLvl Collation                      Owner
----                 ------          -------------- --------- ---------                      -----
AdventureWorks2012   Normal          Simple               110 SQL_Latin1_General_CP1_CI_AS   matty
TSQL2012             Normal          Full                 110 Latin1_General_CI_AS           matty

To get a listing for the system databases you can do the following. I would imagine there’s a better way (perhaps some equivalent to ls -a?)…but I can’t think of it at the minute1

PS C:powershell> foreach ($DB in ("master", "msdb", "model", "tempdb")) {gi SQLSERVER:\SQL\my_pcinst2012\databases\$DB }

Name                 Status          Recovery Model CompatLvl Collation                      Owner
----                 ------          -------------- --------- ---------                      -----
master               Normal          Simple               110 Latin1_General_CI_AS           sa
msdb                 Normal          Simple               110 Latin1_General_CI_AS           sa
model                Normal          Simple               110 Latin1_General_CI_AS           sa
tempdb               Normal          Simple               110 Latin1_General_CI_AS           sa

  1. The ‘better way’ is to use gci -force. That includes all the system databases. ↩︎

penflip markdown cheatsheet

This is extracted from Adam Pritchard’s Markdown Cheatsheet.

It’s what I would see as the useful bits….but of course my useful bits won’t be the same as your useful bits!

Feature Code
Heading #
Bold __bold__
Italics _italics_
Strikout ~~italics~~
Numbered list 1. First
Numbered list __1. First second level with space not underscores
Numbered list 2. Second
Numbered list __Indent under list with space not underscores
Link [Link](https://mattypenny.net)
Image ![alt text](hhttp://i2.wp.com/mattypenny.net/wp-content/uploads/2015/01/imagep001-e1423056484537-175x300.jpg?zoom=1.5&resize=90%2C150 "Salisbury Cathedral")
Footnotes [^1].<br>[^1]: Here is the footnote.
Escape _
Blockquotes > Blockquote
Line ---
Html Use html tags

sql server 2005 install hangs at 'Removing Backup Files'

I’m installing sqlserver 2005, and it seemed to hang towards the end of the installation.

The installer hung while it was installing ‘Workstation Components, Books Online’, with the progress message being ‘Removing Backup Files’. As it happened I kicked this off at the end of the day, and it was still hanging the next morning

Sql 2005 progress box

I checked the installer log but there was nothing very interesting

<Func Name='LaunchFunction'>
Function=Set_CommitFlag
<Func Name='GetCAContext'>
<EndFunc Name='GetCAContext' Return='T' GetLastError='0'>
Doing Action: Set_CommitFlag
PerfTime Start: Set_CommitFlag : Mon Jan 26 16:46:51 2015
<Func Name='Set_CommitFlag'>
Can I commit?
Set_CommitFlag called successfully.Committed
<EndFunc Name='Set_CommitFlag' Return='0' GetLastError='0'>
PerfTime Stop: Set_CommitFlag : Mon Jan 26 16:46:51 2015
<EndFunc Name='LaunchFunction' Return='0' GetLastError='0'>

It turned out to be very much a problem between the chair and the keyboad.

At the start of the install I’d had this warning message: Sql 2005 warning message

I wasn’t too worried about it - I’m installing an old version of SQL on a newer OS - but I left the warning message window open…partly so that I could investigate further later.

Anyway…as soon as I shut that warning window down, the install kicked back into life and soon completed.

sql server 2005 install hangs at 'Removing Backup Files'

I’m installing sqlserver 2005, and it seemed to hang towards the end of the installation.

The installer hung while it was installing ‘Workstation Components, Books Online’, with the progress message being ‘Removing Backup Files’. As it happened I kicked this off at the end of the day, and it was still hanging the next morning

Sql 2005 progress box

I checked the installer log but there was nothing very interesting

<Func Name='LaunchFunction'>
Function=Set_CommitFlag
<Func Name='GetCAContext'>
<EndFunc Name='GetCAContext' Return='T' GetLastError='0'>
Doing Action: Set_CommitFlag
PerfTime Start: Set_CommitFlag : Mon Jan 26 16:46:51 2015
<Func Name='Set_CommitFlag'>
Can I commit?
Set_CommitFlag called successfully.Committed
<EndFunc Name='Set_CommitFlag' Return='0' GetLastError='0'>
PerfTime Stop: Set_CommitFlag : Mon Jan 26 16:46:51 2015
<EndFunc Name='LaunchFunction' Return='0' GetLastError='0'>

It turned out to be very much a problem between the chair and the keyboad.

At the start of the install I’d had this warning message: Sql 2005 warning message

I wasn’t too worried about it - I’m installing an old version of SQL on a newer OS - but I left the warning message window open…partly so that I could investigate further later.

Anyway…as soon as I shut that warning window down, the install kicked back into life and soon completed.

Problem: php commenting out not working in wordpress

This was a bit of a ‘Duh!’ moment.

I use the following to ‘comment out’ chunks of Wordpress pages that I’m still working on


<?php /*
Some old rubbish that I have'nt finished working on yet
*/?>

This seemed to have ‘stopped working’.

The reason was my ‘Exec-PHP’ plugin was de-activated. I don’t remember de-activating it. I guess it’s possible that an automat(t)ic update might have done so, but I don’t know.

How to do a sql server equivalent of Oracle 'set feedback on'

I haven’t been able to find a T-sql equivalent of the Oracle ‘set feedback on’, which outputs a line telling you how many rows have been effected by the last sql statement.

The closest thing, I think, is:

select 'Rows updated: ' + CAST(@@ROWCOUNT as varchar(10))

How to generate the t-sql to disable all your triggers

This seems to work:

SELECT
     'disable trigger ' + USER_NAME(trig.schema_id) + '.' +  trig.name +
     ' on ' +
     USER_NAME(tab.schema_id) + '.' + OBJECT_NAME(trig.parent_object_id) +
     char(10) +
     'go'
FROM sys.objects trig
INNER JOIN sys.objects tab
    ON trig.parent_object_id = tab.object_id
WHERE trig.type = 'TR'

It generates sql like this:

disable trigger dbo.tr_AfterUpdate on dbo.BigTable
go
disable trigger dbo.tr_BeforeUpdate on dbo.BigTable
go

How to generate the t-sql to disable all your triggers

This seems to work:

SELECT
     'disable trigger ' + USER_NAME(trig.schema_id) + '.' +  trig.name +
     ' on ' +
     USER_NAME(tab.schema_id) + '.' + OBJECT_NAME(trig.parent_object_id) +
     char(10) +
     'go'
FROM sys.objects trig
INNER JOIN sys.objects tab
    ON trig.parent_object_id = tab.object_id
WHERE trig.type = 'TR'

It generates sql like this:

disable trigger dbo.tr_AfterUpdate on dbo.BigTable
go
disable trigger dbo.tr_BeforeUpdate on dbo.BigTable
go

How to use t-sql to show SSRS permissions

I’m not great at T-sql, and I know that cursors are unfashionable in Microsoft world, but this gives me the output I want, as below:

PathUsernameGrantedPermissions
/Data SourcescfcjmourinhoBrowser,Content Manager,My Reports,Publisher,Report Builder
/Data Sources/StatszoneBUILTINAdministratorsContent Manager
/Data Sources/StatszonecfcjmourinhoBrowser,Content Manager,My Reports,Publisher,Report Builder
/Data Sources/StatszonecfcjmourinhoBrowser,Content Manager,My Reports,Publisher,Report Builder
/zTest/By far the greatest team reportcfcjmourinhoBrowser,Content Manager,My Reports,Publisher,Report Builder
/zTest/By far the greatest team reportcfcbbuckBrowser
/zTest/By far the greatest team reportcfcrfariaContent Manager
drop table #ReportPermissions

create table #ReportPermissions
(Path varchar(100),
 Username varchar(100),
 GrantedPermissions varchar(100))


declare
  UserWithPermissionsCursor cursor for
  select -- ,roles.[RoleID]
      rolename
      -- ,users.[UserID]
      ,username
      -- ,catalog.[PolicyID]
      ,path
  FROM [ReportServerRep01].[dbo].[PolicyUserRole],
       roles,
       users,
       catalog
where policyuserrole.RoleID = roles.roleid
and   policyuserrole.UserID = users.userid
and   policyuserrole.policyid = catalog.PolicyID
order by path, username, rolename

declare @rolename varchar(100)
declare @username varchar(100)
declare @path varchar(100)
declare @PermissionsString varchar(100)
declare @Savedusername varchar(100)
declare @Savedpath varchar(100)


open UserWithPermissionsCursor
FETCH UserWithPermissionsCursor INTO @rolename, @username, @path

WHILE 0 = @@fetch_status
BEGIN
 if (@SavedUserName = @username AND @SavedPath = @path)

    set @PermissionsString = @PermissionsString + ',' + @Rolename

 else
 begin
    -- Output the line
    insert into #ReportPermissions
    (Path,
     Username,
     GrantedPermissions)
    values
    (@SavedPath,
     @SavedUserName,
     @PermissionsString)

    -- Reinitialize variables
    set @SavedPath = @path
    set @SavedUsername = @username
    set @PermissionsString = @rolename

 end

 FETCH UserWithPermissionsCursor INTO @rolename, @username, @path

END
close UserWithPermissionsCursor
deallocate UserWithPermissionsCursor

select * from #ReportPermissions

Problem: ssrs error: 'System.Data.OracleClient requires Oracle client software version 8.1.7 or greater'

A quick post on a quick fix.

I installed Sql Server Reporting Services 2008 R2 on the report server, then installed Oracle client 11.2.0.4.

I copied across a valid tnsnames.ora file, and verified connectivity with both sqlplus and tnsping.

However, trying to connect to one of the Oracle databases from within SSRS I got:

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater

…helpfully highlighted in an angry red.

Fix is fairly straightforward - SSRS hadn’t picked up the change to %PATH% done by the Oracle install yet, so the fix was to re-start the SSRS service.

Problem: ssrs error: 'System.Data.OracleClient requires Oracle client software version 8.1.7 or greater'

A quick post on a quick fix.

I installed Sql Server Reporting Services 2008 R2 on the report server, then installed Oracle client 11.2.0.4.

I copied across a valid tnsnames.ora file, and verified connectivity with both sqlplus and tnsping.

However, trying to connect to one of the Oracle databases from within SSRS I got:

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater

…helpfully highlighted in an angry red.

Fix is fairly straightforward - SSRS hadn’t picked up the change to %PATH% done by the Oracle install yet, so the fix was to re-start the SSRS service.

Powershell pattern matching to check if a string is hex

Hexadecimal-counting I’ve been playing with pattern matching in Powershell.

I was trying to use ‘-match’ to ‘Check if the string is a hexadecimal number’ for the ‘Perl one-liners in Powershell’ page I’ve been working on.

I can’t pretend to entirely understand or explain pattern matching in Powershell, or in linux, but this seems to work.

$X = "21e" ; $Y = $X.length ; $X -match "[0123456789abcde]{$Y}"

This says match the string against ‘any combination of the characters within the square brackets (i.e. the hex digits) to the same length as the original string’.

So, the square brackets contain the allowable characters.

The curly brackets give the number of characters.

I tried just doing:

$X = "21e" ; $X -match "[0123456789abcde]{$X.length}"

…but this didn’t seem to work.

Tests

I tried the following strings - they all seemed to come up with the right answer: ``` $ $X = "21e" ; $Y = $X.length ; $X -match "[0123456789abcde]{$Y}" True $ $X = "21edjhsd" ; $Y = $X.length ; $X -match "[0123456789abcde]{$Y}" False $ $X = "21e34782348237847832748723" ; $Y = $X.length ; $X -match "[0123456789abcde]{$Y}" True $ $X = "21e34782348237847832748723f" ; $Y = $X.length ; $X -match "[0123456789abcde]{$Y}" False $ $X = "21e34782348237847832748723acbdaaa" ; $Y = $X.length ; $X -match "[0123456789abcde]{$Y}" True $ $X = " " ; $Y = $X.length ; $X -match "[0123456789abcde]{$Y}" False ```

….although I’m not sure whether this is right or wrong:

$ $X = "" ; $Y = $X.length ; $X -match "[0123456789abcde]{$Y}"
True

notes about wordpress version of salisburyandstonehenge.net

SalisburyThis page is a bit of documentation for how I do stuff on the multifarious websites that I’ve perpetrated over the years. These are very much notes for myself but if anybody else should happen upon this page I hope you find it useful :)

On This Day - how it works

These are a couple of vim things I use regularly.

My local history website has a list of stuff that happened on this day' in Salisbury’s history

I maintain the list by adding a page for each event into a Wordpress page structure that looks like this:

  • on-this-day
    • month
    • event page, title of which is prefixed by the date

I fill in the event pages' ‘Order’ field (under ‘Page Attributes’) with the day of the month. The months' ‘Order’ field has the ‘number of the month’ (i.e. 1 is January, 2 is February etc). This keeps everything in order.

Then the top level page has this:

    <ul class="sitemap-pages">
    
    

I think I’m going to change this to have a separate wp_list_pages for each month. This will allow me to have a table of contents, although it will slow it down, I guess.

On This Day - reformatting from dynamic list of Wordpress child pages to static list for the weekly post

Anyhoo, I use the top level list to create a weekly post, summarizing that weeks events in Salisbury history.

There are a couple of vim things that help me do that.

When I grab the page source from the top level list, each page looks like this:

<li class="page_item page-item-7354"><a href="/on-this-day/april/28th-april-1948-terry-pratchetts-birthday">28th April 1948 - Terry Pratchett's birthday</a>

which looks like this on the page:

  • 28th April 1948 - Terry Pratchett's birthday

    I could just cut and paste that, but I think it looks a little bit nicer, in the context of a post to do the following, in gvim.

    This removes the ‘class=“page_item page-item-7354”’ bit. I’m not sure what it’s for but I’m pretty sure it’s not useful in this context

    :%s/ class="page_item page-item-[0-9][0-9]*"//

    Then I’m moving the date out of the anchor text to the start of the line. I could probably do this in one hit, but for the time being I’m mapping a key and then executing it manually once for each line

    :map b />[0-9]ld4w0lllp

    Then typing ‘b’ renders the html like this:

    <li>6th April 1967 - <a href="/on-this-day/april/6th-april-1967-pink-floyd-play-salisbury-city-hall">Pink Floyd play Salisbury City Hall</a>

    …which looks like this:

  • 6th April 1967 - Pink Floyd play Salisbury City Hall

    I prefer this for the posts.

    On This Day - reformatting for the Parish Mag

    A slight variation on the above - this is for re-formatting the On This Day stuff for the Parish mag

    map q /[0-9][0-9][0-9][0-9] dw$A (pi).
    

    then

    / May
    cw: 
    

    WH Smith Deep Linking

    Go to the Deep Link page:

    https://www.affiliatewindow.com/affiliates/customise_link.php?mid=3017

    Paste in the URL from the product page:

    This generates a Deep Link:

    <a href="http://www.awin1.com/cread.php?awinmid=3017&awinaffid=171527&clickref=Notes%20From%20a%20Small%20Island&p=http%3A%2F%2Fwww.whsmith.co.uk%2Fproducts%2Fnotes-from-a-small-island%2Fproduct%2F9780552996006" target="_top">WHSmith</a>

    For a simple text link that’s all you need.

    Pic: The book cover is an ‘affliate link’, which means that if you click on it it will take you to the

    and

    If you buy anything on Smith’s website I get a commission. The image is copyrighted, but because it’s essentially a way of advertizing the product, so I think that this is ‘fair use’

    Insert the image as normal. This gives you some html like this:

    ```Bill Bryson - Notes from a Small Island ```

    Replace the anchor text section (i.e. ‘WHSmith') with the image spec from what was inserted from the Wordpress gallery

    <a href="http://www.awin1.com/cread.php?awinmid=3017&awinaffid=171527&clickref=Notes%20From%20a%20Small%20Island&p=http%3A%2F%2Fwww.whsmith.co.uk%2Fproducts%2Fnotes-from-a-small-island%2Fproduct%2F9780552996006" target="_top"><img src="/images/Bill-Bryson-Notes-from-a-Small-Island-192x300.jpg" alt="Bill Bryson - Notes from a Small Island" width="192" height="300" class="alignright size-medium wp-image-9114" /></a>

  • Problem: SSIS: 'Hresult: 0x800703E6 Description: Invalid access to memory location'

    Windover House, Saint Anne Street from Wilts Arch and Nat Hist MagProblem came up trying to connect to a remote Oracle source:

    Started:  12:03:03
    Error: 2013-10-09 12:03:03.84
       Code: 0xC0202009
       Source: 
       Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x800703E6.
    An OLE DB record is available.  Source: "Microsoft OLE DB Service Components"  Hresult: 0x800703E6  Description: "Invalid access to memory location.".
    End Error
    Error: 2013-10-09 12:03:03.84
       Code: 0xC020801C
       Source: Copy Data
       Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "xxx" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.
    End Error
    Error: 2013-10-09 12:03:03.84
       Code: 0xC0047017
       Source: xxxx
       Description: component "xxx" (1) failed validation and returned error code 0xC020801C.
    End Error
    DTExec: The package execution returned DTSER_FAILURE (1).
    

    Fix was to go into job step properties, select the ‘Execution options’ tab and click on ‘Use 32-bit runtime’.

    I’m wondering whether we had an Oracle 32-bit install, or a 32-bit install that wasn’t entirely removed