Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best Way To Do This
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01520112
Message ID:
01520173
Views:
47
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
Previous
Reply
Map
View

Click here to load this message in the networking platform