Geoff writes "Hi,I need to apply a set of standard names to the company namesstored in our Goldmine database. The STANDARDNAMES tablelooks like this:STANDARDNAME GMNAME=======================...IBM IBMIBM IBM CorpIBM I.B.M....
A way to update one table with another might be this:UPDATE dbo.CONTACT1SET dbo.CONTACT1.COMPANY = dbo.STANDARDNAMES.STANDARDNAMEFROM dbo.STANDARDNAMESWHEREdbo.CONTACT1.COMPANY = dbo.STANDARDNAMES.GMNAME
Except, in this case the "SET ..." can't be done- I need to use the GMW_WriteContact stored procedureinstead, otherwise I'll muck up the GoldMine databasein pretty short order. I have used the stored procedure,but then I have to use the following algorithm which isextremely inefficient: I have to run a SELECT statementon the STANDARDNAME list once for every record in theGoldmine database.Can anyone suggest a better way?Cheers,Geoff.OPEN CompanyCursorFETCH CompanyCursor INTO @CompanyName, @TempRecID/* Loop over all Goldmine Records */WHILE (@@FETCH_STATUS=0) BEGIN /* Search the STANDARDNAMES GMNAME column for this Company name */SELECT @StandardName = dbo.STANDARDNAMES.Company, @Variation =dbo.STANDARDNAMES.VARIATIONFROM dbo.STANDARDNAMESWHERE (dbo.STANDARDNAMES.VARIATION = @CompanyName)/* Update the Goldmine Company Name if there is a single match */IF ((@@ROWCOUNT = 1) AND (@StandardName <> @CompanyName)) BEGIN EXEC @Status = dbo.GMW_WriteContact @gmnvENDFETCH CompanyCursor INTO @CompanyName, @TempRecIDENDCLOSE CompanyCursorDEALLOCATE CompanyCursor
"