2010/08/30

Error "Violation of PRIMARY KEY constraint 'PK_Name'. Cannot insert duplicate key in object 'dbo.Table'" when applying snapshot to the Subscriber database

When setting up merge replication, you may get the following error:
Violation of PRIMARY KEY constraint 'PK_Name'. Cannot insert duplicate key in object 'dbo.Table'
while the initial snapshot is applied to the Subscriber database.

How can data that violates no primary key constraints at the Publisher cause such an error at the Subscriber? This can be caused by different collations used by the Publisher and Subscriber (at the database, table or column level).

If the Publisher database has a case-sensitive collation (e.g. SQL_Latin1_General_CP1_CS_AS ), the following data is correct (columns Type and Code are a primary key):

Type  Code  Column1
024   N     ...
024   n     ...
024   g     ...

However, an attempt to insert these rows into a table with case-insensitive collation (e.g. Latin1_General_CI_AI) will cause a primary key violation.

2010/08/23

Filter results in SQL Server Management Studio may be case-sensitive

If you are working with a database that has a case-sensitive collation (e.g. Latin1_General_CS_AS), the filter function in SQL Server Management Studio will use this setting and the results will be case-sensitive.

Filter showing tables with Bitmap in the name:


Filter showing tables with bitmap in the name:



If this database had a case-insensitive collation, filter results for Bitmap and bitmap would be identical and would contain all four tables.

2010/03/10

Spotify global hotkeys - AutoHotkey script

My script is based on one I found here.

Hotkeys:

Previous trackWin+1
Play/pauseWin+2
Next trackWin+3
Volume downWin+Q
Volume upWin+W

Script:
#1::
; Previous track
ControlSend, ahk_parent, ^{Left}, ahk_class SpotifyMainWindow
return

#2::
; Play/pause
ControlSend, ahk_parent, {Space}, ahk_class SpotifyMainWindow
return

#3::
; Next track
ControlSend, ahk_parent, ^{Right}, ahk_class SpotifyMainWindow
return

#q::
; Volume down
ControlSend, ahk_parent, ^{Down}, ahk_class SpotifyMainWindow
return

#w::
; Volume up
ControlSend, ahk_parent, ^{Up}, ahk_class SpotifyMainWindow
return
How does it work:

It's very simple - I just mapped my favourite audio player hotkeys to default Spotify keyboard shortcuts, e.g. #1 means Win+1 in AutoHotkey syntax and pressing this hotkey sends ^{Left} (i.e. Crtl+Left) to main window of Spotify application.

2010/01/12

Web Parts Maintenance Page - fixing a SharePoint page with faulty Web Parts configuration

If you ever use Site Aggregator Web Part on the default.aspx page of a site and configure it in a way that redirects users to some other website (specified when adding Site Aggregator) every time they try to open the SharePoint site (I have no idea how I managed to do it), you can use the Web Parts Maintenance Page to resolve this problem. Of course, you can use this page to troubleshoot all other kinds of problems caused by Web Parts misconfiguration.


The URL of the Web Parts Maintenance Page is:

http://SITE-URL/_layouts/spcontnt.aspx?&url=%2fPAGE-WITH-WEB-PARTS.aspx

2010/01/02

BSoD when installing Windows XP on ASUS K61IC notebook

If a bluescreen (Blue Screen of Death) occurs during Windows XP installation and the error message contains the 0x0000007B code, try to do the following:
  1. restart the notebook,
  2. press F2 to enter the BIOS setup,
  3. go to Advanced and then IDE Configuration,
  4. change the SATA Operation Mode setting to Compatible (the default setting is Enhanced).
Some information about the STOP: 0x0000007B error can be found here.