torsdag den 20. juni 2013

Biztalk Sql Agent Job Failed orphaned messages

Today I received an alert on a failing Sql Agent Job on a Biztalk Sql Server. The job was failing cause of errors in the Biztalk Msg Database. The cure for the issue is by using the Terminator Tool. More information on Tord's blog: http://biztalkadmin.com/orphaned-messages-in-the-tracking-database/

torsdag den 8. november 2012

RDP - session hanging

In some cases on some systems I have experienced that my RDP session hangs, and the only thing I can see when logging in on the server is a black screen.

When this happens I have 2 options:

  1. Complain, complain and complain
  2. Call some support fellow, or disturb a colleague who might happen to have access to the same server, and let him kill my RDP session
But this was until today, when I thought to myself: Myself, there must be another way, and there is. Using the commands: quser.exe /server:[servername] from a different server actually tells you which users logged on to the target server. Read out the session-id from the user you want to "kill" and use: logout [session-id] /server:[servername]. This will do the trick.

Thanks Dan Rigsby for sharing this [http://www.danrigsby.com/blog/index.php/2008/08/26/remotely-log-off-remote-desktop-users/]

fredag den 26. oktober 2012

Are your SQL Server Queries slow?

Run this query to see if any of your indexes needs a rebuild or reorganize:
(linked back from this site: http://weblogs.asp.net/okloeten/archive/2009/01/05/6819737.aspx)

SELECT 'ALTER INDEX [' + ix.name + '] ON [' + s.name + '].[' + t.name + '] ' +
       CASE WHEN ps.avg_fragmentation_in_percent > 40 THEN 'REBUILD' ELSE 'REORGANIZE' END +
       CASE WHEN pc.partition_count > 1 THEN ' PARTITION = ' + cast(ps.partition_number as nvarchar(max)) ELSE '' END
FROM   sys.indexes AS ix INNER JOIN sys.tables t
           ON t.object_id = ix.object_id
       INNER JOIN sys.schemas s
           ON t.schema_id = s.schema_id
       INNER JOIN (SELECT object_id, index_id, avg_fragmentation_in_percent, partition_number
                   FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL)) ps
           ON t.object_id = ps.object_id AND ix.index_id = ps.index_id
       INNER JOIN (SELECT object_id, index_id, COUNT(DISTINCT partition_number) AS partition_count
                   FROM sys.partitions
                   GROUP BY object_id, index_id) pc
           ON t.object_id = pc.object_id AND ix.index_id = pc.index_id
WHERE  ps.avg_fragmentation_in_percent > 10 AND
       ix.name IS NOT NULL

onsdag den 3. oktober 2012

SQL Server Bulk Insert

How to insert bulk data into a SQL Server Table from a CSV file:


BULK
INSERT TugLookup
FROM 'c:\temp\tuglookup.csv'
WITH
(
FIELDTERMINATOR = ';',
ROWTERMINATOR = '\n'
)
GO
--Check the content of the table.
SELECT *
FROM TugLookup
GO

torsdag den 7. juni 2012

Notes on BizTalk 2010

Some notes around installing and configuration of BizTalk 2010

The installation was done on a virtualized Win 2008R2. Follow this document from Microsoft:

The installation consists of following components:
- SQL Server 2008R2 with SSAS,SSRS and SSIS installed. But be sure to read the installation guide
- Visual Studio 2010 (download the trial version from Microsoft)
- Configuration of the SQL Server (deactivate shared memory on the instance)
- Installation of BizTalk 2010
- Configuration of BizTalk 2010

After this, launch the Administration application.

Tutorial for developing your first BizTalk solution:

torsdag den 26. april 2012

Create multiple scheduled tasks across n-servers

Needed to create the same scheduled task on several servers. Using a bit of Powershell made the task a bit easier. Below functions can be used to create, delete and view scheduled tasks on a specific server:

Function Get-ScheduledTask
 {
 param([string]$ComputerName = "localhost")
 Write-Host "Computer: $ComputerName"
 $Command = "schtasks.exe /query /s $ComputerName"
 Invoke-Expression $Command
 Clear-Variable Command -ErrorAction SilentlyContinue
 Write-Host "`n"
 }
 
# EXAMPLE: Get-ScheduledTask -ComputerName Server01
 
Function Remove-ScheduledTask
 {
 param(
 [string]$ComputerName = "localhost",
 [string]$TaskName = "blank"
 )
 If ((Get-ScheduledTask -ComputerName $ComputerName) -match $TaskName)
  {
  If ((Read-Host "Are you sure you want to remove task $TaskName from $ComputerName(y/n)") -eq "y")
   {
   $Command = "schtasks.exe /delete /s $ComputerName /tn $TaskName /F"
   Invoke-Expression $Command
   Clear-Variable Command -ErrorAction SilentlyContinue
   }
  }
 Else
  {
  Write-Warning "Task $TaskName not found on $ComputerName"
  }
 }
 
# EXAMPLE: Remove-ScheduledTask -ComputerName Server01 -TaskName MyTask
 
Function Create-ScheduledTask
 {
 param(
 [string]$ComputerName = "localhost",
 [string]$RunAsUser = "System",
 [string]$TaskName = "MyTask",
 [string]$TaskRun = '"C:\Program Files\Scripts\Script.vbs"',
 [string]$Schedule = "Monthly",
 [string]$Modifier = "second",
 [string]$Days = "SUN",
 [string]$Months = '"MAR,JUN,SEP,DEC"',
 [string]$StartTime = "13:00",
 [string]$EndTime = "17:00",
 [string]$Interval = "60" 
 )
 Write-Host "Computer: $ComputerName"
 $Command = "schtasks.exe /create /s $ComputerName /ru $RunAsUser /tn $TaskName /tr $TaskRun /sc $Schedule /mo $Modifier /d $Days /m $Months /st $StartTime /et $EndTime /ri $Interval /F"
 Invoke-Expression $Command
 Clear-Variable Command -ErrorAction SilentlyContinue
 Write-Host "`n"
 }
 
# EXAMPLE: Create-ScheduledTask -ComputerName MyServer -TaskName MyTask02 -TaskRun "D:\scripts\script2.vbs"

Borrowed from: this link 

søndag den 25. marts 2012

Doing the BI Certification with Koenig-Solutions in Dubai - Part I

Going to Dubai from Copenhagen is quite easy. I found a flight with Qatar Airways. A quick stop in Doha before arrival in Dubai (1 hour) was OK. Landed in Dubai at 2.10am local time and was kind of tired. Unfortunately many people had choosen to go to Dubai, so getting through customs took about an hour. From here it should be painless, but my suitcase was apparently forgotten in Doha. Luckily many flights go from Doha to Dubai so only 30 minutes of waiting and of to the Koenig Apartment. But now the local time was 4.15am. A quick call to Koenig caretakers to tell them I was coming resultet in a quick welcome and showing to my flat and room. A nice big flat with 2 rooms and 2 bedrooms. Breakfast was at 8am, so not much time to sleep.

A quick shower and rushing to the breakfast which includes eggs, toast, fresh fruit, juice and several types of cerials. Even the ones my kids are not allowed to eat. Then off to the Koenig Office for starting the course, using the Koenig Bus which transports all people, including instructors, to the office. A nice blend of indian, oman, american and danish blend in that bus. At the office the manager at the office welcomed me, informed about the reimbursement of taxi trip and daily cost for lunch. The lunch at the office is done at "food court" where several fast-food stores are present, including KFC and Subway, but also indian and italian style food. Pretty ok selection. Back to what I came for, the SQL 2008 BI course. The instructor - Prakash - introduced to the course, with a overview of the different elements in the course and then we startet. Being the only one on the team is pretty ok. The instruction is a mix of using the traditional (...veryyyyy traditional) Microsoft stuff, with slides and some pretty boring lab exercises. But Prakash also uses a simple whiteboard for introducting the subjects and explaning what the comming module would contain. And this is actually ok. At least when the lab exercies are spiced up with improvised exercises where things not goes as the theory says. And most often, this is where the potential and skills of the instructor becomes visible. But so far its going well. At 13 o'clock it's time for a 1 hour lunch break, which seams like appropriate. Getting some lunch and some rest in the sun is nice. At 17 o'clock the instruction is done, and around 17:15 the bus takes us back to the apartment.

So to sum it up, the experience so far has been positive. The course is going well, so far almost covered the SSAS area in 2 days, been to the pool twice, ran 5 kilometers and had some interesting conversations with the two caretakers.