I have a select statement that returns 76 rows. Following is a piece of the procedure
As is @numRecordsCopied shows as 0.
If I take out the "if" statement down to the "end", @numRecordsCopied correctly shows as 76.
Why does the if statement mess up the @@rowcount? I know it would be change it if I were to do something like:
select @@error
But I am not doing that?
I did find that I could get it to work if I did the following:
Why is this?
Thanks,
Tom.
Code:
exec ("select * into " + @tableName + " from openquery(north,'select * from tblCustomers')")
if @@error <> 0
begin
print "@@error = "
print @@error
end
select @numRecordsCopied = @@rowcount
print @numRecordsCopied
As is @numRecordsCopied shows as 0.
If I take out the "if" statement down to the "end", @numRecordsCopied correctly shows as 76.
Why does the if statement mess up the @@rowcount? I know it would be change it if I were to do something like:
select @@error
But I am not doing that?
I did find that I could get it to work if I did the following:
Code:
exec ("select * into " + @tableName + " from openquery(north,'select * from tblCustomers')")
select @numRecordsCopied = @@rowcount, @error = @@error
if @error <> 0
begin
print "@@error = "
print @@error
end
print @numRecordsCopied
Why is this?
Thanks,
Tom.