Showing posts with label Microsoft SQL Server. Show all posts
Showing posts with label Microsoft SQL Server. Show all posts

2008-09-05

SQL Server 2005 Service Pack 2 is not successfully updated when you try to install or to uninstall security update KB948108 or security update KB94810

When you try to install the July 2008 security update for Microsoft SQL Server 2005 Service Pack 2 (security updates KB948108 and KB948109), Microsoft SQL Server 2005 is not successfully updated. Additionally, when you try to uninstall the security update, the security update is not uninstalled.

http://support.microsoft.com/kb/957008

2007-11-08

Unterschiedliche Datensätze in zwei Tabellen ermitteln

Wir erstellen zwei neue Tabellen mithilfe der CREATE TABLE-Anweisung.

Die beiden Tabellen werden als Country1 und Country2 benannt.

Die ersten zwei Datensätze mit der ID 1 und 2 beinhalten gleiche Ländernamen.

Der Datensatz mit der ID 3 hat unterschiedliche Werte und der Datensatz mit der ID 4 ist nur in der Country2-Tabelle vorhanden.

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Country1]([ID] [int] NOT NULL,
[Country] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL)

INSERT INTO [dbo].[Country1] ([ID],[Country]) VALUES (1, 'SWITZERLAND')
INSERT INTO [dbo].[Country1] ([ID],[Country]) VALUES (2, 'GERMANY')
INSERT INTO [dbo].[Country1] ([ID],[Country]) VALUES (3, 'AUSTRIA')

CREATE TABLE [dbo].[Country2]([ID] [int] NOT NULL,
[Country] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL)

INSERT INTO [dbo].[Country2] ([ID],[Country]) VALUES (1, 'SWITZERLAND')
INSERT INTO [dbo].[Country2] ([ID],[Country]) VALUES (2, 'GERMANY')
INSERT INTO [dbo].[Country2] ([ID],[Country]) VALUES (3, 'TURKIYE')
INSERT INTO [dbo].[Country2] ([ID],[Country]) VALUES (4, 'ITALY')


Wir möchten herausfinden, welche Datensätze in beiden Tabellen unterschiedlich sind. Die unterschiedlichen Datensätze werden aufgelistet.



Die folgende SQL-Anweisung hilft uns, die unterschiedlichen Datensätze aus beiden Tabellen zu ermitteln.



SELECT 'Country1' TableName, *, BINARY_CHECKSUM(*) BINARY_CHECKSUM_Value
FROM [Country1]
WHERE BINARY_CHECKSUM(*) NOT IN (SELECT BINARY_CHECKSUM(*) FROM [Country2])
UNION ALL SELECT 'Country2' TableName, *, BINARY_CHECKSUM(*) BINARY_CHECKSUM_Value
FROM [Country2] WHERE BINARY_CHECKSUM(*) NOT IN (SELECT BINARY_CHECKSUM(*)
FROM [Country1]) ORDER BY ID, 1


Als Resultat erhalten wir folgende Liste:



¦TableName¦ID---------¦Country-----------------------¦BINARY_CHECKSUM_Value¦
¦
---------¦-----------¦------------------------------¦---------------------¦
¦Country1
-¦3----------¦AUSTRIA-----------------------¦1141249761-----------¦
¦Country2
-¦3----------¦TURKIYE-----------------------¦1359412453-----------¦
¦Country2
-¦4----------¦ITALY-------------------------¦4982233--------------¦