How about this. In the last INSERT INTO...SELECT you posted, try something like this INSERT INTO #Temp (txtName, txtICN, txtBusUnit, intTotal ) SELECT a.txtName, a.txtInternetCompNum, a.txtAccountingCode,(SELECT COUNT(*) FROM Another_Table at WHERE at.ICn = @ICN AND at.AccountingCode = a.AccountingCode)FROM Account aWHERE txtInternetCompNum = @icn
Tough to read, but something like that should work. Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda>