UNIQUE INDEX vs multiple NULL values

In Microsoft SQL Server, if you want to make sure that a column contains no duplicates, you can use the UNIQUE keyword to enforce this constraint, either by creating a unique index or by adding a unique constraint to the column. It’s very useful and nice, but… What about NULL values? I mean, obviously, you can insert the first NULL value, but what if you have more null values and you need to enforce only the uniqueness of the non-null values? Continue reading ‘UNIQUE INDEX vs multiple NULL values’ »

Out-of-place restore érdekes mellékhatása

Éppen játszottam replikációval SQL2008-on, és az AdventureWorks adatbázist akartam replikálni, amikor a Log Reader Agent a vidám futás helyett az alábbi hibaüzenettel halt el rögtön indulás után:

Cannot execute as the database principal because the principal "dbo" does not exist,
this type of principal cannot be impersonated, or you do not have permission.

Ez elszomorított, majd guglival eltaláltam a http://support.microsoft.com/kb/913423 oldalra, ahol azt állítják, hogy restore után megesik, hogy nem tudok EXECUTE AS parancsot futtatni. Ezen elgondolkoztam, mert én soha még csak el sem mentettem egyetlen adatbázist arról a tesztszerverről, de be kellett látnom az igazát. Az AdventureWorks telepítése tulajdonképpen egy adatbázis restore. És mivel nem az én gépemen készült eredetileg, ezért a database owner szerepét illetően zavar támadt, és el kellett mondani, hogy sp_changedbowner. Aztán minden szép és jó lett. És ez sem tudja elvenni a kedvemet a 2005-től meg a 2008-tól.