Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best Way To Do This
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01520112
Message ID:
01520173
Vues:
44
Actually, some of your code makes no sense. Why do you start explicit transaction? Why do you check @@ROWCOUNT after SELECT @@ROWCOUNT? Why do you commit transaction only if it's 0?

In any case, it also looks like you didn't use Boris loop idea and went with one command.

>Here's what I used, and it worked fine.
>
>
>USE Indiana_ODS_VT
>/*
>SELECT TOP 100 * FROM FarmersImport
>SELECT TOP 100 * FROM tblCamp_CT_Kevin
>*/
>
>
>UPDATE tblCamp_CT_Kevin SET Farmer = NULL
>SELECT @@ROWCOUNT
>-- Returns 696397
>
>BEGIN
> 
>    BEGIN TRANSACTION
> 
>    UPDATE tblCamp_CT_Kevin SET Farmer = '1'
>		FROM tblCamp_CT_Kevin c
>		INNER JOIN FarmersImport fi ON LTRIM(RTRIM(fi.[FirstName])) = LTRIM(RTRIM(c.FName)) AND
>									   LTRIM(RTRIM(fi.[LastName])) = LTRIM(RTRIM(c.LName)) AND
>									   LTRIM(RTRIM(fi.[RegCity])) = LTRIM(RTRIM(c.City))
>		WHERE c.Farmer IS NULL
>
>	SELECT @@ROWCOUNT
>
>--39604 with MailCity
>--39701 with RegCity
>
>    IF @@ROWCOUNT = 0
>      BEGIN
>        COMMIT TRANSACTION
>      END
>	ELSE
>      BEGIN
>        ROLLBACK
>      END
>
> END
>
>
>Thanks everyone
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform