Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why did this update unexpected table?

Status
Not open for further replies.

jenlion

IS-IT--Management
Nov 13, 2001
215
I wrote the following query to update a table in a mysql database from sql server. I cannot figure out why this wound up updating the updatedate field for some 3000 records on the linked SQL server. It should have been the source of updated fields. I can't tell what it might have updated, if anything, unfortunately. I hope nothing, but it's got my name and 3000 updated records. Why did this hit my SQL table when I told it to update the MySQL table??
Code:
update Cust
Set CustID = C.CustID, CustName = C.CustName, CreditLimit = C.CreditLimit, PrimaryAddrKey = C.PrimaryAddrKey, DfltBillToAddrKey=C.DfltBillToAddrKey, 
PrimaryCntctKey=C.PrimaryCntctKey, MasUpdateDate = C.UpdateDate
from LinkedMysqlServer...Customer Cust join LinkedSQLServer.DBName.dbo.tablename C (nolock) on Cust.CustKey = C.CustKey
where abs(datediff(s,C.UpdateDate,Cust.MasUpdatedate)) > 5
 
It shouldn't have. Is there a trigger on the MySql table that updates the SQL table?


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
No, that's the wild thing. No triggers on the Mysql table.

It doesn't appear that any major data in the SQL DB is changed... I don't think. The SQL database's triggers log changes to major data in that table, and nothing from me is logged there. But those same triggers decided to put my login and the date I ran the query in its update fields, so clearly it 'thinks' I did *something*. I've never seen that behavior before, and I've been in these databases for years now.

And of course it's the production DB, since I have - HAD - no qualms about querying a live database and writing its data to a development environment. (Hence the nolock). Sheesh. Guess I'll go back to making more copies and querying the recent copy until I understand WTF happened there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top